|
Class Trouble
Hello Everyone,
I''m having a problem which is driving me nuts. This is the first time that I am using classes in my application and I''m having trouble with the snippet of code below. My compiler (MSVC++ 6) keeps telling me that the constructor is not allowed a return type, yet my constructor doesn''t seem to be returning anything.
Does anyone know what is going on?
Signatures? We don''t need no stinking signatures!
April 27, 2001 12:07 PM
I think your problem is that the compiler defaults to an interger return type. Declaring the following:
function_x()
{
}
says function x returns an int.
but to return nothing
you need a void return type.
in C++ constructors have to have a void return type.
the proper version of your code should look like this
class myClass {
public:
void myClass(); //construtor declaration
}
actual implementation:
void myClass::myClass(){
//do anything here except return a value.
}
function_x()
{
}
says function x returns an int.
but to return nothing
you need a void return type.
in C++ constructors have to have a void return type.
the proper version of your code should look like this
class myClass {
public:
void myClass(); //construtor declaration
}
actual implementation:
void myClass::myClass(){
//do anything here except return a value.
}
Well, if there is actually a "class CDirect3D" defined, then the constructor will not default to an int return-type.
I think you need to provide more info, reaptide, because the code as shown is correct.
Also, make sure you aren't specifying any return type in your actual class declaration.
// CHRIS
Edited by - win32mfc on April 27, 2001 1:26:18 PM
I think you need to provide more info, reaptide, because the code as shown is correct.
Also, make sure you aren't specifying any return type in your actual class declaration.
// CHRIS
Edited by - win32mfc on April 27, 2001 1:26:18 PM
// CHRIS [win32mfc]
Thanks for the responses guys. Unfortunatly MSVC++ won''t let you declare a return type for a constructor, so declaring a void in the constructor won''t work.
As for additional info, here it is, hope it helps:
That''s the full listing for my CDirect3D Class.
Signatures? We don''t need no stinking signatures!
As for additional info, here it is, hope it helps:
|
That''s the full listing for my CDirect3D Class.
Signatures? We don''t need no stinking signatures!
yo are simjply missing a semicolon after the last breacket of the class...... };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement