Sign in to follow this  

problem with a class/object (simple)

This topic is 3456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

currently I'm trying to learn myself c++ and i got a problem with a class I'm trying to make, my compiler (visual c++ express edition 2008) gives me this error 1>c:\users\trixed\documents\visual studio 2008\projects\hello_world\hello_world\hello.cpp(5) : error C2533: 'Cat::{ctor}' : constructors not allowed a return type as far as i can see in my code i don't declare a return type for it, can anyone help me with it? and here is my code: class.h class Cat { public: Cat (int initialAge); ~Cat(); int GetAge() const {return itsAge;} void SetAge(int age) { itsAge = age;} void Meow() const {std::cout << "Meow.\n";} private: int itsAge; } and hello.cpp #include <iostream> #include "class.h" Cat::Cat(int initialAge) { itsAge = initialAge; } Cat::~Cat() { } int main() { Cat Frisky(5); Frisky.Meow(); std::cout << "Frisky is a cat who is "; std::cout << Frisky.GetAge() << " years old.\n"; Frisky.Meow(); Frisky.SetAge(7); std::cout << "Now Frisky is "; std::cout << Frisky.GetAge() << " years old.\n"; return 0; }

Share this post


Link to post
Share on other sites

This topic is 3456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this