// default constructor
Marble::Marble(Color c){ color = c; }
 
// default constructor
Marble::Marble(Size s)  { size = s; }

--- On Thu, 6/4/09, Robert Ryan <[email protected]> wrote:


From: Robert Ryan <[email protected]>
Subject: [c-prog] constructor problem
To: [email protected]
Date: Thursday, June 4, 2009, 2:51 PM








#include <iostream> 
#include "Marble.h"
 
int main()
{
                        Marble m1;
                        Marble m2(Marble::red) ;
                        cout << m1;
}
 
 
#include "Marble.h"
// default constructor
Marble::Marble( )
{          color = Color::red;
            size = (Size)2;  }
 
// default constructor
Marble::Marble( Color c){    }
 
 
// default constructor
Marble::Marble( Size s){    }
 
// default constructor
Marble::Marble( Color c, Size s){    }
 
// default constructor
Color Marble::get_ Color() //const{     return Color;  }
 
// default constructor
Size Marble::get_ Size()  //const   {     return Size;   } 
 
ostream& operator<<(ostream& os, const Marble& m)
{
            string col, size;
            switch (m.get_color( )) {
                        case 0:                         col = "red";            
                  break;
                        case 1:                         col = "red";            
                  break;
                        case 3:                         col = "red";            
                  break;  }
            switch (m.get_size( )) {
                        case 0:                         size = 3;               
                    break;
                        case 1:                         size = 5;               
                    break;
                        case 3:                         size = 7;               
                    break;
            }
                        os << "(" <<  col << "," <<  size << ")" ;
}
 

Error    2          error C2039: 'get_Color' : is not a member of 
'Marble'           h:\cs221\hw1\ hw1\hw1\marble. cpp    33
 
Error    3          error C2146: syntax error : missing ';' before identifier 
'get_Color'            h:\cs221\hw1\ hw1\hw1\marble. cpp    33
 
Error    4          error C4430: missing type specifier - int assumed. Note: 
C++ does not support default-int            h:\cs221\hw1\ hw1\hw1\marble. 
cpp    33
 
Error    5          error C4430: missing type specifier - int assumed. Note: 
C++ does not support default-int            h:\cs221\hw1\ hw1\hw1\marble. 
cpp    34
 
Error    6          error C2039: 'get_Size' : is not a member of 'Marble' 
h:\cs221\hw1\ hw1\hw1\marble. cpp    39
 
Error    7          error C2146: syntax error : missing ';' before identifier 
'get_Size'            h:\cs221\hw1\ hw1\hw1\marble. cpp    39
 
Error    8          error C4430: missing type specifier - int assumed. Note: 
C++ does not support default-int            h:\cs221\hw1\ hw1\hw1\marble. 
cpp    39

[Non-text portions of this message have been removed]

















      

[Non-text portions of this message have been removed]

Reply via email to