0
//array of pointers to person objects
#include<iostream.h>
class Person
{
protected:
	char name[40];
public:
	void getname()
	{
		cout<<"\n Enter name:";
		cin.getline(name,40);

	}

	void putname()
	{

		cout<<"\n Name="<<name;

	}

};

void main()
{
	Person*persptr[100];
	int n=0;
	char choice;
	do{
		persptr[n]=new Person;
		persptr[n]->getname();
		n++;
		cout<<"\n Enter another(y/n)? ";
		cin>>choice;

	}while(choice=='y');

	for(int i=0;i<n;i++)
	{
		cout<<"\n Person Number"<<i+1;
		persptr[i]->putname();
	}

}

**I access microsoft visual c++ 6.0. I'm beginner in learning C++. Error mentioned that my program requires a reinterpret_cast , a c_style cast or function_style cast.**
Anybody can helps me?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by vijayan121
0

> Error mentioned that my program requires a reinterpret_cast , a c_style cast or function_style cast.**
the code you posted does not give that particular error.
the two errors in your code are
a. #include <iostream.h> is not standard c++. replace this with #include <iostream> and using namespace std; b. main *must* return an int (not void).

when you run the code, there would also be a problem because of whitespaces left in the input buffer after cin>>choice ; . but you could deal with that after getting the program to compile without errors

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.