Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Confusing Conundrum

Name: Anonymous 2007-01-31 10:58

I have a question about class inheritance:
I create two classes such as this:

class Student {};
class GraduateStudent : Student{};

initialize like so:

Student* pStudent;
pStudent = new Student();

and I get "55 expected constructor, destructor, or type conversion before '=' token"
the thing is though, only in my current project...if i just create a new one, it compiles just dandily. any clue what's happening? I'm using the latest dev-cpp, btw. Is it some sort of compiler option that I would have added to my project?

Name: Anonymous 2007-01-31 11:37

FUCK OFF

Name: Anonymous 2007-01-31 14:21

>>1
you need a public derivation:

class GraduateStudent: public Student {};

and initialize like:

pStudent = new GraduateStudent; // remove the ()

Name: Anonymous 2007-01-31 15:18

>>1
Hint:

class Student:
    pass

class GraduateStudent(Student):
    pass

student = Student()
#Extra hint: shitCase sucks. Use FunctionsCase and variables_case.

Name: Anonymous 2007-01-31 15:37

>>3
oops, typo. i had that in there

Name: Anonymous 2007-01-31 15:39

p = new Student; // OK
p = new GraduateStudent; // BAD: private inheritance of automatic default constructor

Name: Anonymous 2007-01-31 17:28

Just look at the definitions of Student and GraduateStudent. If your language makes any difference from them, it fails.

Name: Anonymous 2009-01-14 14:05

Its useless

Name: Anonymous 2011-01-31 20:13

<-- check em dubz

Name: Anonymous 2011-02-02 23:33

Name: Sgt.Kabu榭kiman띓ꃤ 2012-05-28 22:22

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List