C++ Books

# This is a modification of the original "Polymorphism is my Birthday ?" topic.
# Moderators, feel free to move this to the lounge.
# Old problem:


Well, I'm just barely getting into Polymorphic programming. Here's my bad attempt at it. The C++ MinGW compiler acts really strange with the syntax, and I don't know how to correct it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
typedef unsigned char Byte;

struct RGB
{
	Byte red;
	Byte green;
	Byte blue;
	RGB(Byte Red, Byte Green, Byte Blue): red(Red), green(Green), blue(Blue){}
};

struct RGBA : public RGB
{
	Byte alpha;
	RGBA(Byte red, Byte green, Byte blue, Byte alpha): red(red), green(green), blue(blue), alpha(alpha){}
};


Please help correct my syntax. I did check through some tutorials on polymorphism but they were hard to understand, which is why I want some professional help (books).

# Recent Discussion

Also, I understand that my 16th birthday is coming soon, on the 19th of April. I'm pretty spoiled about this.. Of course, I want a car programming books. Please suggest what I should ask for.

1. I'm looking for hands-on, thorough books that teach the essentials to skillful usage of C++. Maybe something from Bjarne Stroustrup, or likewise ? http://www2.research.att.com/~bs/homepage.html

2. I want to get into modern processing (threading/concurrency), and learn information about the 'latest-and-greatest' practical C++ programming. C++0x? Boost?

3. It would be extremely handy to have books about low level craft. They should explain essential knowledge about parsing, compiling, linking etc. I want to write a special resource compiler which is compatible with GCC/MinGW object files.

If you also know of good online resources related to these, please let me know!

Thanks in advanced.. and don't forget to say 'Happy Birthday!'
Last edited on
Screw your birthday, mine is tomorrow.

Anyways,
red(this->red), green(this->green), blue(this->blue), alpha(this->alpha)
I think that should work.
closed account (D80DSL3A)
Use the base class constructor in the RGBA class constructor.
1
2
3
4
5
struct RGBA : public RGB
{
	Byte alpha;
	RGBA(Byte Red, Byte Green, Byte Blue, Byte Alpha): RGB(Red,Green,Blue), alpha(Alpha){}
};

EDIT: NVM 2nd comment
Last edited on
That didn't fix it completely. I should say that the classes are actually within a namespace, and I have a source file which includes this after it includes Windows.h. Does that make conflicts?
Last edited on
closed account (D80DSL3A)
I don't know if that is causing a problem.
Please provide a better error description than
compiler acts really strange
That's not very informative.
Sorry. But, It was acting strange. I saw errors in the compile log that weren't supposed to be related to my issue. It was because of this:

http://msdn.microsoft.com/en-us/library/dd162937%28v=VS.85%29.aspx

..Since I was including Windows.h in before these declarations. And the namespace I have isn't making any effect. I fixed the problem by renaming them colorRGB, and colorRGBA.

Now it's time for the fun part: Books.
Topic archived. No new replies allowed.