Search:

Type: Posts; User: johnnyd

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    14
    Views
    17,605

    Thanks all. Problem solved. ( You guys are good...

    Thanks all. Problem solved. ( You guys are good :D)
  2. Replies
    14
    Views
    17,605

    I'm glad you posted PJYelton, because from your...

    I'm glad you posted PJYelton, because from your code:



    vector<myclass> vec1;


    would give me the compile error I mentioned earlier. Whereas, in your case, where MS VC++6 you said, it...
  3. Replies
    14
    Views
    17,605

    No, what I meant was, do most people build their...

    No, what I meant was, do most people build their classes with the assignment operator overloaded and have a copy constructor? The reason I ask is because the text (and most other sources) do not...
  4. Replies
    14
    Views
    17,605

    You see, it's things like that which annoy me....

    You see, it's things like that which annoy me. :mad: They [the text] tell you how to do everything except the most important thing. Now how was I supposed to know that vectors for user defined...
  5. Replies
    14
    Views
    17,605

    Yes, a vector of objects. You know it's...

    Yes, a vector of objects. You know it's interesting, that's exactly how I defined my vector of objects. Check this:



    vector<Book> vBook;


    Which is supposed to be a vector of books. However,...
  6. Replies
    14
    Views
    17,605

    I agree, it should. It's just that it doesn't...

    I agree, it should. It's just that it doesn't work when I use my own custom defined types. I was wondering if there was something else that I needed to do. Hence, the post. Any ideas?
  7. Replies
    14
    Views
    17,605

    How To use vectors for custom classes

    Hey folks. Question: How do you implement Vectors for a user defined class? Is this even possible? I've searched the boards, the faq and the tutorials and all of them only refer to using the...
  8. Thread: Hehe =)

    by johnnyd
    Replies
    18
    Views
    2,018

    Polymorphic... how far away from the Microsoft...

    Polymorphic... how far away from the Microsoft Bldg are you situated?
  9. Replies
    24
    Views
    4,526

    STRESS!! Can you imagine? I actually went back...

    STRESS!!

    Can you imagine? I actually went back to my bashy gui ridden C project from last year that Prelude helped me out with and I actually checked out the files that were written to the hard...
  10. Replies
    24
    Views
    4,526

    I finally realised what I was doing wrong why...

    I finally realised what I was doing wrong why fstream wasn't working for me. It was because everytime I read the record, the file pointer moves to the beginning of the next record. Therefore, I have...
  11. Replies
    24
    Views
    4,526

    Got it. It's a shame though that C's...

    Got it. It's a shame though that C's implementation of files was so much simpler and more reliable. I get the feeling that somehow they were trying to reinvent the wheel with the text mode and it...
  12. Replies
    24
    Views
    4,526

    That's interesting Swoopy, I've never thought of...

    That's interesting Swoopy, I've never thought of that one. I'll give it a shot.
  13. Replies
    24
    Views
    4,526

    I just tested it and it works. All the time. ...

    I just tested it and it works. All the time.

    I've come to realise why binary mode wasn't working for me. It was because I used fstream to create the file handler, and not ofstream. ofstream works...
  14. Replies
    24
    Views
    4,526

    Gotcha. Starting afresh... (I wish they told...

    Gotcha.

    Starting afresh... (I wish they told us these things in school and in books)
  15. Replies
    24
    Views
    4,526

    When you say text, do you mean that all of the...

    When you say text, do you mean that all of the variables in the class should be of the char* type? or do you mean text as in a literal string like "The quick brown fox was nuked by the lazy dog"?
  16. Replies
    24
    Views
    4,526

    I've actually tried that. It doesn't work. And...

    I've actually tried that. It doesn't work. And exactly as how you typed it too!
  17. Replies
    24
    Views
    4,526

    No it's not being opened in binary. It's in text...

    No it's not being opened in binary. It's in text mode. Here's how I play with it:



    obook.open("books.dat", ios::ate);
    if (obook){
    newBook = Book(isbn, author, title, publisher, pPlace,...
  18. Replies
    24
    Views
    4,526

    Why would ofstream not work sometimes?

    Check out the following code:



    obook.write(reinterpret_cast< const char * >(&newBook), sizeof(Book));


    ...where obook is an ofstream variable that opens a file using ios::ate and newBook is...
  19. Replies
    5
    Views
    3,788

    I'm just realising that. Thanks for the keen eye....

    I'm just realising that. Thanks for the keen eye. ;)
  20. Replies
    5
    Views
    3,788

    Alas, I believe you have hit the nail on the...

    Alas, I believe you have hit the nail on the head. I didn't know it made a difference. Thanks again Codeplug.

    It would seem as if I have to totally abandon the Deitel and Deitel 4th ed. It is...
  21. Replies
    5
    Views
    3,788

    This works fine: Book test; //Book is my...

    This works fine:



    Book test; //Book is my custom class
    ifstream inbook("book.dat", ios::in);
    ofstream outbook "book.dat", ios::ate);
    inbook.read(reinterpret_cast< char* >(&test),...
  22. Replies
    5
    Views
    3,788

    Are fstream and ofstream incompatible?

    Hi all...

    I have not seen a faq or post that matches my problem. Hopefully, you folks can lend me your expertise once again.

    I'm using random files to store some data. When I use ofstream to...
  23. Thanks Codeplug - works beautifully. I just...

    Thanks Codeplug - works beautifully. I just wished you had been a little clearer in the first post regarding the Deitel and Deitel. Essentially you had already answered my question.

    But I think...
  24. Umm... Codeplug... I'd hate to break this to...

    Umm... Codeplug... I'd hate to break this to ya... but that doesn't seem to work either.

    Can you declare a variable to do BOTH reading (read) and writing? (write)

    That's what I am trying to do....
  25. Thanks Codeplug - I think it's more of my...

    Thanks Codeplug - I think it's more of my misreading your post. Sorry...

    It's still a lot more work than C though. :D
Results 1 to 25 of 70
Page 1 of 3 1 2 3