having trouble splitting a main file into 2 classes.

This is a discussion on having trouble splitting a main file into 2 classes. within the C++ Programming forums, part of the General Programming Boards category; recently I having some assignment that requires me to create a screen scraping application using C++ which is my 1st ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    6

    having trouble splitting a main file into 2 classes.

    recently I having some assignment that requires me to create a screen scraping application using C++ which is my 1st time handling using this program language. fortunately, I manage to code it everything into the main file. but the requirement requires at least 2 classes. Anyone can help me?? I need it urgently.. Thank you

  2. #2
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    Quote Originally Posted by lorenzo86 View Post
    ... I manage to code it everything into the main file. but ...
    post it
    Asking a question you already know the answer to might teach you something you did not know...

  3. #3
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    Check this out first.
    That will make it easier for people to help you.
    Asking a question you already know the answer to might teach you something you did not know...

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    very sorry, my original code is nicely formatted. but i did not know y it auto-left indented after I post it.

  5. #5
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    :/ not quite...
    Preveiew your post before you submit! Honestly do you expect people to read that code, try to decide what it's overall function is supposed to be, and help with it? Most people will not even read it. Make sure it is indented, don't be too scared to toss in a comment or two, and maybe explain your goal a little. (what the program is needed for)
    You asked for class suggestions, just explaining what you are attempting to do may provide suggestions for that without any code.
    Asking a question you already know the answer to might teach you something you did not know...

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    my apologies to you regarding the messy codes and description is not stated clearly.. I had make changes on the indent of the code. and the description as follows:

    I'm required to do a screen scraping applcation using c++ to grab information from a html file(in the code which i name it as "test.html"). it is a webpage from Yahoo! Finance - Business Finance, Stock Market, Quotes, News. I supposed to get the indices of specific stock e.g. Dow, FTSE, Nikkei, STI..

    As the project requirement, I supposed to make at least 2 classes. which is parser and matchpattern class but I don't what should I do.

  7. #7
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    Quote Originally Posted by lorenzo86 View Post
    parser and matchpattern
    Think of what data you are working with, then think of ways they are related, if any.
    Think of what you DO to/with the data, your methods/functions, and find relations between the data and the methods. You should be able to sum up most of the work into the two classes and anything remaining will be outside of them. (perhaps a third class or in main...)
    Asking a question you already know the answer to might teach you something you did not know...

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Yes. I did think of that. But I am totally noob in this programme language. How do i relate 2 class. and main?

  9. #9
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    It looks like you just don't quite grasp object oriented programming, I hope I am wrong as I do not mean anything offensive by it. But looking at the code and your questions, I think you should google c++ class examples. Get an understanding of what a class provides in general, and it will be clear how to use classes in your code.
    Asking a question you already know the answer to might teach you something you did not know...

  10. #10
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    you are right, I'm not good in O.O.P. and I did google for c++ especially classes portion. I just couldn't understand or split my programme base on the codes I have. Example: which code should i put in parser class and which part should i put in matchpattern class.

  11. #11
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    I have purposely dodged providing that direct relation to your work because it seems to me that is the actual point of the assignment. To show your understanding of classes. Give it a try yourself first. Don't worry about getting it all right the first time. Consider your data. You have so many global variables above main. In reality all or at least most of them would not be global (I did not actually look them over one by one). Rather than a global variable classes can be accessed globally and contain variables. From inside a class you can set them public, private, protected. So look for a relation to the type of data you are working on, what data types you need, what data will need work done on it, what will happen with the result. These methods will be another part of the class which holds the data. You must be able to find some relations on your own, given that you have made it this far.
    Asking a question you already know the answer to might teach you something you did not know...

  12. #12
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Thank you.

  13. #13
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    Give it a shot and post what you come up with. You will get it figured out! Plus once you start working on it and figure some things out, you will find other things just seem to fall into place.
    Asking a question you already know the answer to might teach you something you did not know...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21