Thread: Quick class question

  1. #1
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118

    Quick class question

    Hi everyone

    I made a class with 4 private variables of the type int, int, bool, bool respectively. Say I called it "MyClass". I write the constructors and functions to retrieve the private variables and it all compiles. So far so good.

    The trouble occurs when I try to use the constructor of the form

    Code:
    int a = 5;
    int b = 2;
    bool c = true;
    bool d = false;
    
    MyClass C = (a, b, c, d);
    I get the error msg

    "conversion from `bool' to non-scalar type `MyClass' requested"

    Anyone know what's wrong? It isn't obvious to me and I can't think where to look.

    I can post more source code if people would like

    Kind Regards

    Stonehambey

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    probably = should not be there...
    you are trying to assign to your C var the result of (a,b,c,d) which is d - read the "operator , " description
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118
    That seems to have worked, thanks

    I'll read up on what you suggest

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NOOB class question
    By wart101 in forum C++ Programming
    Replies: 38
    Last Post: 01-12-2007, 12:29 AM
  2. class question
    By l2u in forum C++ Programming
    Replies: 5
    Last Post: 12-02-2006, 04:55 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Difficulty superclassing EDIT window class
    By cDir in forum Windows Programming
    Replies: 7
    Last Post: 02-21-2002, 05:06 PM