--- 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;
  };

> student::student()
> {
> //cout<<"i am constructor"<<endl;
>     strcpy(name,"\0");
>     stunum=0;
> }

Use the constructor syntax...!

  student::student() : name(), stunum() { }

Note the default constructor for POD types is to zero
initialise them.

> void student::setvalue(char * a)

  void student::setvalue(const char * a)

<snip>     
>     system("PAUSE");

Don't do this!! On my system it just generates the output...

  ksh: PAUSE:  not found

...for which you would get 0 for the assignment if I was the
marker! ;)

Learn to launch a console and test from a command line.

-- 
Peter

Reply via email to