Thread: constructor overloading

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    113

    constructor overloading

    hi I'm learning c++ from a book , now I'm trying to solve an exercise that you need to use overload constructors, here is my code actually it works fine but I need to know if it is the right way to do it.

    please excuse my poor english.

    Code:
    class MyClass{
           public:
                MyClass(char *); //constructor 1
                MyClass(int *);  //constructor 2
                MyClass(float *); //constructor 3
               
               //rest of code here, etc...
    };

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    should work. Whether it is the best way to do it depends on the rest of the class.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Well it's legal, but without knowing what MyClass is being used for I can't tell if it's the right thing to do.
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    113
    ok, thanks
    I really only need to know if its legal,
    thanks for the reply

Popular pages Recent additions subscribe to a feed