Why does my loop loops 3 times when i have only 2 line of data in my file? From the cout << s.size , when i run it will show 1,2,3.
Information in txt file
local john 10/2/1990
international...
Type: Posts; User: Alexius Lim
Why does my loop loops 3 times when i have only 2 line of data in my file? From the cout << s.size , when i run it will show 1,2,3.
Information in txt file
local john 10/2/1990
international...
Can u explain this?
if (ss >> nationality)
{
clsStudent* student = nullptr;
if (nationality == "Local")
{
student = new...
How to i read data from file into my program when there is 2 types of classes inside the file?
In my txt file i have something like this.
Local John IC_number State
International Bob ...
Well how do i determine if its a cat or a dog?
my print() function here is virtual. So in this case, the program determines itself which class it's in and calls the correct print function.
...
I know how to read from file and I know polymorphism but i do not know how to implement them together.
this is my virtual function readFromFile for localStudent.
void...
How do i read inputs from file with polymorphism? How is the program going to detect if its a (lets say) a dog or a cat? and stores the information accordingly? Perhaps show me a brief example?...
Haha, my mistake. Thanks
this?
ofstream out(filename, ios::app);
do i need to do anything to make it append at the end of file?
I have a vector of students and im trying to write them into a txt file. However, it will only write 1 student only. I also am not really sure on how to implement read file also. I got something in...
This is what i got.
while (getline(cin, line))
{
stringstream ss(line);
if (ss >> input && ss.eof() && (input == 1 || input == 2))
{
break;
...
what about the validation for
input != 1 && input != 2 now that the datatype is stringstream, how do i check if the input is 1 or 2?
My delete is not working. Why?
struct MatchName
{
MatchName(string& searchName) : s_(searchName) {}
bool operator()(const clsStudent* student) const
{
return...
I have this simple code for input validation where the only options are 1 and 2. But if the user entered a character, the loop becomes never-ending. How do i validate for incorrect input datatype?
...
minor mistake while copying
void clsLocalStudent::print()
{
cout << "\nStudent Name\t\t\t: " << getName()
<< "\nDate of Birth\t\t\t: " << getDateOfBirth()
<< "\nProgram...
i have a localstudent and internationalstudent class inherit from student class. read and print are virtual functions. After i have set all the member variables when i wan to print out all the...
im doing it like this.
in student class
void clsStudent::setAccounts(clsAccount *argAccounts)
{
accounts = argAccounts;
}
Erm. Student has accounts. And within these accounts, it has other accounts information such as the name amount etc. I'm trying to set those members.
it gave me an error
[/COLOR][/SIZE][/FONT]
How to i access setter from within a setter?
i know that getter methods can be access like
getAccounts().getAccountNumber(); // for example
but for setters how do i do it? this doesnt...
i'll fixed the problem. change my code to this =)
setProgram(&objProgram[0]);
thanks for the explaination
because my programs will ask the user for all the program information. then when the user is prompt to select program he will only choose 1, 2 or 3. so the name, code and fees (which are not included...
clsUniversityProgram has string programName.
in my main i have this. I have found out that my error is at the setProgram(&selectProgram) part but i do not know how to fixed it. when i try to print, my program crashes. read and print are virtual...
i see... thanks. By the way, why is putting cout in input operator overloading a bad practice?
anyone have any idea how to ask the user to enter for each attributes without using cout in my operator overloading >> ? I still want to print out the Enter program name etc but not inside this...