Search:

Type: Posts; User: Alexius Lim

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds; generated 51 minute(s) ago.

  1. Replies
    4
    Views
    1,907

    File stream loop

    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...
  2. Replies
    3
    Views
    3,739

    Can u explain this? if (ss >> nationality) ...

    Can u explain this?


    if (ss >> nationality)
    {
    clsStudent* student = nullptr;
    if (nationality == "Local")
    {
    student = new...
  3. Replies
    3
    Views
    3,739

    reading from file (polymorphism)

    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 ...
  4. Replies
    7
    Views
    2,049

    Well how do i determine if its a cat or a dog?...

    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.


    ...
  5. Replies
    7
    Views
    2,049

    I know how to read from file and I know...

    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...
  6. Replies
    7
    Views
    2,049

    File IO with polymorphism

    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?...
  7. Replies
    5
    Views
    1,413

    Haha, my mistake. Thanks

    Haha, my mistake. Thanks
  8. Replies
    5
    Views
    1,413

    this? ofstream out(filename, ios::app); do i...

    this?

    ofstream out(filename, ios::app);
    do i need to do anything to make it append at the end of file?
  9. Replies
    5
    Views
    1,413

    file IO only writing for 1 element

    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...
  10. Replies
    5
    Views
    2,529

    This is what i got. while (getline(cin,...

    This is what i got.


    while (getline(cin, line))
    {
    stringstream ss(line);
    if (ss >> input && ss.eof() && (input == 1 || input == 2))
    {
    break;
    ...
  11. Replies
    5
    Views
    2,529

    what about the validation for input != 1 &&...

    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?
  12. Replies
    4
    Views
    1,272

    vector delete not functioning...

    My delete is not working. Why?



    struct MatchName
    {
    MatchName(string& searchName) : s_(searchName) {}
    bool operator()(const clsStudent* student) const
    {
    return...
  13. Replies
    5
    Views
    2,529

    input validation

    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?
    ...
  14. minor mistake while copying void...

    minor mistake while copying


    void clsLocalStudent::print()
    {
    cout << "\nStudent Name\t\t\t: " << getName()
    << "\nDate of Birth\t\t\t: " << getDateOfBirth()
    << "\nProgram...
  15. program crashes while printing data from vectors

    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...
  16. Replies
    7
    Views
    1,108

    im doing it like this. in student class ...

    im doing it like this.

    in student class


    void clsStudent::setAccounts(clsAccount *argAccounts)
    {
    accounts = argAccounts;
    }
  17. Replies
    7
    Views
    1,108

    Erm. Student has accounts. And within these...

    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.
  18. Replies
    7
    Views
    1,108

    it gave me an error [/COLOR][/SIZE][/FONT]

    it gave me an error
    [/COLOR][/SIZE][/FONT]
  19. Replies
    7
    Views
    1,108

    accessing setter methods

    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...
  20. Replies
    5
    Views
    924

    i'll fixed the problem. change my code to this =)...

    i'll fixed the problem. change my code to this =)

    setProgram(&objProgram[0]);

    thanks for the explaination
  21. Replies
    5
    Views
    924

    because my programs will ask the user for all the...

    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...
  22. Replies
    5
    Views
    924

    clsUniversityProgram has string programName.

    clsUniversityProgram has string programName.
  23. Replies
    5
    Views
    924

    How to fix this? pointer

    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...
  24. Replies
    4
    Views
    1,209

    i see... thanks. By the way, why is putting cout...

    i see... thanks. By the way, why is putting cout in input operator overloading a bad practice?
  25. Replies
    4
    Views
    1,209

    operator overloading >>

    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...
Results 1 to 25 of 59
Page 1 of 3 1 2 3