B
baje
hi
new to c++; have an array to hold five names; however having problems
reading in the names into the array.here the code i have
#include<iostream>
using std::cout;
using namespace std;
#include<conio.h>
#include<iomanip>
#include<string>
class Names
{
private:
char lastname[5];
public:
Names::lastname();
void setnames();
//default Constructor function initialises array
Names::names()
{
for (int i = 0; i < 5; i++)
{
strcpy(lastname, "");
}
}
void setnames()
{
for (int i = 0; i < 5; i++)
{
cin.getline(lastname, 30))//not working to read in five names
}
}
new to c++; have an array to hold five names; however having problems
reading in the names into the array.here the code i have
#include<iostream>
using std::cout;
using namespace std;
#include<conio.h>
#include<iomanip>
#include<string>
class Names
{
private:
char lastname[5];
public:
Names::lastname();
void setnames();
//default Constructor function initialises array
Names::names()
{
for (int i = 0; i < 5; i++)
{
strcpy(lastname, "");
}
}
void setnames()
{
for (int i = 0; i < 5; i++)
{
cin.getline(lastname, 30))//not working to read in five names
}
}