peternilsson42 wrote:
> --- In [email protected], "iamwljiang" <iamwlji...@...> wrote:
>> #include<iostream>
>> #include<string.h>
> 
> Use <cstring>, or better still <string>.
> 
>> #include<cstdlib>
>> using namespace std;
>>
>> class student
>> {
>> private:
> 
> It's a class, the default access is already private.
> 
>>     char name[50];
>>     int stunum;
>>     
>> public:   
>>     student();
>>     ~student()
>>     {
>>     cout<<"i am destructor"<<endl;
>>     }
>>
>>     void setvalue(char *);    
>>     void display();
> 
> You should make display a const function.
> 
> Actually, you should not have a display function. You should
> set up an ostream::operator << friend function.
> 
>> };
> 
> I've never understood why people don't declare classes...
> 
>   struct student
>   {
>     student();
>     ~student() { cout << "i am destructor" << endl; }
>     void setvalue(const char *);    
>     void display() const;
> 
>   private:
>     char name[50];
>     int stunum;
>   };

Because it looks weird?  To mentally differentiate my C background from 
C++, 'struct' = data storage only (even though I know otherwise), and 
'class' = member functions and data storage.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to