Quick class question

This is a discussion on Quick class question within the C++ Programming forums, part of the General Programming Boards category; Hi everyone I made a class with 4 private variables of the type int, int, bool, bool respectively. Say I ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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-11-2007, 11:29 PM
  2. class question
    By l2u in forum C++ Programming
    Replies: 5
    Last Post: 12-02-2006, 03:55 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10: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, 04:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21