462 Posted Topics

Member Avatar for triumphost

I have just came across a class for the first time ever that does not have variables in any of it's declarations but has them in the implementation. Why is this class behaviour allowed? What are the benefits of not putting variable names? class Testing { public: Testing(int, int, int); …

Member Avatar for deceptikon
0
130
Member Avatar for blitzkrieg64

You haven't provided enough for me to guess what your trying to do.. You also cannot just implicitly convert a HWND to an HDC. It doesn't work like that. Putting the code in order, you can see that you had some HWND's being used as if it was a DC. …

Member Avatar for Moschops
0
282
Member Avatar for godzab

People class doesn't have a declaration for the default constructor, String needs to be defined through its namespace. std::string X. And std::name because you do not have "using namespace std;" In the people class under the public inheritance, add: People(); And finally, PrintInfo has no definition.

Member Avatar for triumphost
0
132
Member Avatar for infinityblade

Never tested this but the formula seems correct :S RGB to CMY: http://www.easyrgb.com/index.php?X=MATH&H=11#text11 CMY to CMYK: http://www.easyrgb.com/index.php?X=MATH&H=13#text13 EDIT: Oh wow.. didn't realize this was a grave dig -_- void RGBToCMYK(int R, int G, int B, int &C, int &M, int &Y, int &K) { C = 1 - (R / …

Member Avatar for triumphost
0
3K
Member Avatar for triumphost

This works fine. For any type I create (Example): BoxArray& operator -= (const Box& B); BoxArray& operator -= (const BoxArray& BA); BUT when it comes to my literal types like char's and strings and char*'s, I get Ambiguous overloads: StringArray& operator -= (const std::string& S); StringArray& operator -= (const StringArray& …

Member Avatar for triumphost
0
139
Member Avatar for benikens

You need to link the correct .lib/.dll/.a/.o files to your program. `#pragma comment('lib', "user32.dll"); ` Would be an example of doing so in Vs2010. I may have made a mistake doing the code above since I don't have access to a compiler to test atm, but it's something like that. …

Member Avatar for benikens
0
298
Member Avatar for triumphost

Hey when I don't template my classes, I can pass member functions to eachother normally. But when I template it, I get errors. The two functions are defined as so: CustomType& Delete(int Position); CustomType& Delete(T ValueToDelete, bool All = false); CustomType& Delete(CustomType ValuesToDelete); And Implemented like this: template<typename T> CustomType<T>& …

Member Avatar for deceptikon
0
500
Member Avatar for MrEARTHSHAcKER

You did not escape the back-slash character. All strings/literals will have this behaviour as the first back-slash will escape the following character so inorder to have a back-slash, you must escape it with another. You either need to do: `C:\\Directory1\\Directory2\\Music.mp3` OR: `C:/Directory1/Directory2/Music.mp3` Command prompt will complain about the same thing …

Member Avatar for MrEARTHSHAcKER
0
227
Member Avatar for triumphost

How can I do the following but easier? I'm templating a class but I want it so that if typename T is of a literal type such as a string or char, then it can use the following member-function. If not then it cannot use it. I've been using typeid …

Member Avatar for Schol-R-LEA
0
842
Member Avatar for Psyho

http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12 That's what I read to learn template compilation. It says that putting everything in the header can bloat your executable though.

Member Avatar for Psyho
0
322
Member Avatar for Dudearoo

I don't know if you mean reading the file's name? OR whether you mean reading data from the file and outputting a list of names from the data. //Read a file's contents and output it to a string. For your purpose, you can even use GetLine which I have not …

Member Avatar for Lucaci Andrew
0
262
Member Avatar for triumphost

I've read that anonymous structs are a compiler extension and codeblocks allows them as long as -pedantic-errors are not enabled. My question is, since it is not legal in C++, what would be the legal equivalent of: typedef union XYZ { int Color; struct { BYTE X, Y, Z; }; …

Member Avatar for mike_2000_17
0
276
Member Avatar for triumphost

How can I cast a class to another type? Example: class Point { Point(int X, int Y); }; Point A(10, 10); POINT P = (POINT)A; A = (Point)P; //I've tried: Point::Point(POINT P) : X(P.x), Y(P.y), Color(0) {} //Constructor. Point& Point::operator ()(POINT P) { if (X != P.x && Y != …

Member Avatar for mrnutty
0
138
Member Avatar for triumphost

Well I like to learn as much code as I can in a day and I just came across the copy constructor. I do not understand when I need to use it. Do I need to use it for every class I make? I came across it after getting the …

Member Avatar for triumphost
0
279
Member Avatar for sampsont

What you did is already correct.. the reserve allowed it to survive the clear.. Your vector will have a size of 0 but a capacity of 10000. All information in the vector is lost and cannot be accessed. If an access is attempted, it will assert out of range. Basically …

Member Avatar for sampsont
0
798
Member Avatar for triumphost

Yesterday I took a dive into smart pointers and wasn't sure when I should use them vs. Raw pointers. I found out they are quite useful but they do not work all the time for me. Example of working: char* Buffer = new char[1024]; fread(buffer, 1, sizeof(buffer), infile); //took out …

Member Avatar for mike_2000_17
0
234
Member Avatar for triumphost

Why does this say shaddowing? If I change my member X and Y to `_X, _Y` then when I access my class via the dot operator, it shows FOUR values.. Current Class: class Point { public: int X, Y; Point(int X, int Y); ~Point(); }; Point::Point(int X, int Y) : …

Member Avatar for triumphost
0
127
Member Avatar for triumphost

I'm trying to figure out why I should convert all my unsigned ints/shorts to size_t. I'm doing the things below but I'm not sure which one to use and which type to iterator my for-loop with: unsigned short Size() { return vector.size(); } int Size() { return vector.size(); } unsigned …

Member Avatar for triumphost
0
203
Member Avatar for triumphost

Currently I'm reading Multi-String values from the registry. These strings are double null terminated and single null delimiters are between each one. So below I have the following where these are declared as so: std::string KeyToRead, Result; DWORD KeyType. Now I'm returning an std::string aka Result. So I iterated my …

Member Avatar for triumphost
0
465
Member Avatar for triumphost

Why does the below crash? My pointer is still alive and is constructed in the main so it should not die until main returns :S I was using this with createthread a while back but my Mingw4.5 never supported it. I just upgraded to 4.7 but now this crashes and …

Member Avatar for triumphost
0
1K
Member Avatar for triumphost

I have a header file that I include into my main.cpp file. I want to set some flags when this file is included. std::cout.flags(std::ios::boolalpha); I want to set that automatically how can I do this? I tried: #ifdef DEFINES_HPP_INCLUDED std::cout.flags(std::ios::boolalpha); #endif //Gives me the error: //error: 'cout' in namespace 'std' …

Member Avatar for mike_2000_17
0
131
Member Avatar for triumphost

I'm trying to understand recursion and stack overflows. First, why does this not cause a stack overflow? Is it because the function returns every time and that the stack isn't populated upon each call? void Meh() { } int main() { while (true) Meh(); } Two, What is the difference …

Member Avatar for mike_2000_17
0
108
Member Avatar for triumphost

The code below gives me a Narrowing conversion from int to uint32_t: typedef union RGB { uint32_t Color; struct { unsigned char B, G, R, A; }; } *PRGB; inline RGB Rgb(int R, int G, int B) {RGB Result = {((R & 255) << 16) | ((G & 255) << …

Member Avatar for WaltP
0
354
Member Avatar for vytenis555

This may or may not be what you are trying to accomplish: #include "stdafx.h" using namespace System; array<Byte^>^ StringToByteArray(String^ Str) { array<Byte^>^ bytes = gcnew array<Byte^>(Str->Length); for(int I = 0; I < Str->Length; I++) { bytes[I] = Byte(Convert::ToByte(Str[I])); } return bytes; } int main(array<System::String ^> ^args) { array<Byte^>^ bytes = …

Member Avatar for Milton Neal
0
251
Member Avatar for Sendy Hipo

In your assignment operator, you should be checking for self assignment. In your addition/subtraction operators, I'm not sure that you need that temp there. Your ostream works right out of the box. The reason you're getting these errors is because the files aren't added to your debug and release upon …

Member Avatar for Sendy Hipo
0
215
Member Avatar for Nikita Sachdev

Switch to Codeblocks even though I love the Dev-C++ interface, the Mingw for it is far outdated. Also you need to post more detail and probably the function because we cannot guess what you need help with/what the problem may be.

Member Avatar for jaskij
0
193
Member Avatar for triumphost

Can anyone check my memory class and suggest changes or things I may need? I'm writing it so that I don't have to worry about deleting anything everytime I allocate. #include <iostream> template<typename T> class Memory { private: size_t size; T* data; public: explicit Memory(size_t Size) : size(Size), data(new T[Size]){} …

Member Avatar for rubberman
0
140
Member Avatar for triumphost

What's a fast way to fill a union/struct of integral members with ALL Zeroes? RECORD* UNION = {0}; void ZeroStruct(int X, int Y) { UNION = new RECORD[X * Y]; int K = 0; for (int I = 0; I < X; I++) for (int J = 0; J < …

Member Avatar for mike_2000_17
0
272
Member Avatar for triumphost

Is it possible to overload one operator more than once? I have a struct that is just my idea of a C++ Box. I'm trying to increase the size of a box using an integer or another box. I'm trying to do: Box X(0, 0, 0, 0); Box Y(1, 1, …

Member Avatar for triumphost
0
2K
Member Avatar for missil9

From a class I wrote a while back.. I used: <td(.*?)</td> which is a non greedy regex so it will return all matches. Anyway this is the stuff I was speaking of. I used it to create a stock ticker that grabbed Stocks from a website and display their values, …

Member Avatar for missil9
0
318
Member Avatar for triumphost

I have a union defined as so: typedef union RGB { unsigned Color; struct { unsigned char B, G, R, A; }; } *PRGB; I'm reading 32 bit and 24 bit bitmaps. I'm trying to Read Pixels from my RGB union and set pixels as well. I know bitmaps are …

Member Avatar for triumphost
1
446
Member Avatar for jaskij

Allman style.. the others are so difficult to track which braces match which.. well for me at least.

Member Avatar for two[ ][ ]
0
176
Member Avatar for triumphost

I'm trying to have my function return an OPENFILENAME struct. Problem: It returns it fine and everything except that I cannot print the filetitle :S At the moment, it prints the path of the file perfectly fine but when it comes to printing the file title via cout, it prints …

Member Avatar for Ancient Dragon
0
275
Member Avatar for coutnoob

Line 53 as well.. `ostream &Circle::operator << (ostream &mystream,Circle &c)`

Member Avatar for histrungalot
0
351
Member Avatar for jonnyboy12
Member Avatar for triumphost
0
118
Member Avatar for Sunshine2011

For how it could be done see: class Members { private: vector<int> Data; public: Members(){} Members(int I); ~Members(){} int size(); Members& operator [](int I); operator const vector<int>& () const; Members& operator ()(int I); Members& operator << (const int& t); Members& Insert(int Index, int ValueToInsert); Members& Remove(int Index); }; int Members::size(){return …

Member Avatar for Sunshine2011
0
237
Member Avatar for triumphost

What should I be using? Should I be using _T? or L? Or Neither? I know some functions end with the A for Ansi and some end in W for the Unicode version but I have no clue what I want to use. if I use _T would I have …

Member Avatar for ravenous
0
268
Member Avatar for triumphost

Is it necessary to seperate the headers from the source? For example I don't know why but I love to do: //Foo.H class Foo { Foo(){} ~Foo(){} void Func() { //......... //......... } void Func2() { //........ //........ } }; Instead of doing: //Foo.H class Foo { Foo(); ~Foo(); void …

Member Avatar for mike_2000_17
0
2K
Member Avatar for MrEARTHSHAcKER

//For .Net: enum {F9_KEYID = 1, F10_KEYID = 2} ; RegisterHotKey(0, F9_KEYID, MOD_NOREPEAT, VK_F9); RegisterHotKey(0, F10_KEYID, MOD_NOREPEAT, VK_F10); MSG msg = {0}; PeekMessage(&msg, 0, 0, 0, 0x0001); //0x0001 means No Repeat.. TranslateMessage(&msg); switch(msg.message) { case WM_HOTKEY: if(msg.wParam == F9_KEYID) { MessageBox::Show("F9 Pressed"); } else if(msg.wParam == F10_KEYID) { MessageBox::Show("F10 Pressed"); …

Member Avatar for triumphost
0
331
Member Avatar for rannamaa
Member Avatar for triumphost
0
164
Member Avatar for triumphost

Currently I use: DWORD ThreadProc(LPVOID lpParameter) { void (* function)() = (void (*)())lpParameter; function(); return 0; } void Threading(HANDLE &hThread, DWORD &ThreadID, void* FunctionToPass) { hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (void*)FunctionToPass, 0, &ThreadID); } And I want to call it like: Handle hThread; DWORD ThreadID; Threading(hThread, ThreadID, AnyFunctionHere); That way …

Member Avatar for mike_2000_17
0
456
Member Avatar for Suzie999

I don't think you can redistribute their files but if your not using an installer, you could open the project menu -> Properties -> C/C++ -> Code Generation -> RunTime Library Set it to /MDd. Maybe this will work for the installer as well depending on how your making it. …

Member Avatar for Suzie999
0
186
Member Avatar for theashman88

You have to uninstall Mingw first.. and DevC++.. I'm on Windows 8 and it works VS2010 and codeblocks works fine.. Consumer Preview here.

Member Avatar for adityatandon
0
617
Member Avatar for lewashby

I know that the C-Style cast aka (Type)Variable is basically trial an error of all the casts put together. At least that's what I was taught. Example: (double) Variable would be equivalent to trying all of the following and whichever works first, that's used: const_cast<double> Variable reinterpret_cast<double> Variable static_cast<double> Variable. …

Member Avatar for adityatandon
0
149
Member Avatar for iismitch55

Create a WINAPI/Win32 Application.. Remove all the callbacks and stuff.. Use WinMain instead and it will have no console.

Member Avatar for iismitch55
0
930
Member Avatar for triumphost

I want to start developing an IDE or at least a Syntax highlighter into my program. Atm it's a simple text editor with basic copy paste functions. How does Notepad++ do it? Is there a way I can integrate that into my own program? If not then I'll write it …

Member Avatar for mike_2000_17
0
1K
Member Avatar for triumphost

I'm trying to convert My Console classes to .Net classes because I can't use std::vector or anything like that in WindowsFormsApplications. So I decided to convert all Vectors to Lists and I thought that the classes work the same but my code below throws a massive amount of errors and …

Member Avatar for triumphost
0
186
Member Avatar for triumphost

typedef union { unsigned Color; struct { unsigned char B, G, R, A; }; } RGB, *PRGB; inline RGB Rgb(int R, int G, int B) {RGB Result = {((COLORREF)((BYTE)(R)|((BYTE)(G) << 8)|((BYTE)(B) << 16)))}; return Result;} inline RGB Rgb(COLORREF Color) {RGB Result = {Color}; return Result;} The above is my code …

Member Avatar for L7Sqr
0
141
Member Avatar for cppgangster

Deceptikon gave an amazing answer but I want to share what I figured out by accident yesterday. You can declare a function inside a function via a data structure: std::thread f() { typedef struct { void somefunction(){} } t; return t.somefunction(); } //OR std::thread f() { struct t { void …

Member Avatar for deceptikon
0
179
Member Avatar for triumphost

I have the following: typedef union { unsigned Color; struct { unsigned char B, G, R, A; }; } RGB, *PRGB; Then I have: RGB Rgb(XYZ Xyz) { RGB Result; double X = Xyz.X / 100; double Y = Xyz.Y / 100; double Z = Xyz.Z / 100; double Red …

Member Avatar for triumphost
0
953

The End.