using namespace std;
class book
{
private:
char *author[3];
public:
book(char *a)
{
for(int i=0;i<=2;i++)
{
strcpy(author[i],a);
cout<<*(author+i)<<endl;
}
}
};
int main()
{
book b[3]={book("Hi 2 all"),book("Have fun"),book("u all")};
getch();
return 0;
}
Object array
Page 1 of 13 Replies - 124 Views - Last Post: 02 February 2013 - 08:01 AM
#1
Object array
Posted 02 February 2013 - 04:48 AM
The program just crashes without giving any output, explain ?
Replies To: Object array
#2
Re: Object array
Posted 02 February 2013 - 07:56 AM
I've moved this to the C/C++ forum. Please post your help requests in the appropriate language help forums.
#3
Re: Object array
Posted 02 February 2013 - 07:59 AM
There would have been an error message that went along with the crash. What did it say?
Are you sure its really crashing and not just completing then closing?
Instead of getch() why not try getting a full line. That way it requires the [ENTER] key and not just any key still stuck in the keyboard buffer.
Are you sure its really crashing and not just completing then closing?
Instead of getch() why not try getting a full line. That way it requires the [ENTER] key and not just any key still stuck in the keyboard buffer.
Page 1 of 1
|
|

New Topic/Question
This topic is locked



MultiQuote





|