breaking up cpp files / and sourcePage errors

I'm trying to work out how to break up my assignment, I know how to break into 3, as per usual main.cpp driver.cpp and header, but what if I want to add more .cpp files that do different things? do they all have ti implement the header and class myClassName?
I wanted to add another class/ or simply file that dealt with cmd line args, and setting / getting various different parameters. seems a bit silly to have this in main or my driver class as it is a lot of code.

-----------------------

Additionally I only just discovered this page http://cplusplus.com/src/
And went to have a look at the source for notepad, I didn't even have a good look only got to line 20... but the fact that brackets were all over the place, indentation was obscene, and the guy didn't even return an integer(or return anything) from int main().... seems kinda silly to me. Why have source that is retarded?
Last edited on
anyone have any ideas on the adding extra classes/files ? because I have 2 files both using the same class name and header, the object files compiled fine but when trying to compile main it's giving me error :

a2Main.cpp In function int main(int,char**):
a2Main.cpp:61: error: request for member 'checkArgs' in 'ss', which is of non-class type 'StringSort ()()'
a2Main.cpp:62: error:  request for member 'runApp' in 'ss', which is of non-class type 'StringSort ()()'


both checkArgs and runApp are in different files.
Last edited on
Rule #1: never expect open source to be at all readable, understandable, or maintainable.
oh come on, void main() is mad skills :P

on another note, do I have to implement different classes with headers for my file/class problem?
Last edited on
void main() is non-standard, but I'm guessing this program was written before the standard said it
shall be "int main()". Given that the output mechanism works by directly accessing video RAM through
far pointers (which is what shows its age), I'd be surprised if it still ran.

I have no idea how you are trying to break things up or what you are even trying to break up.

All I can say at this point is that each symbol should be declared once and only once, in one header file.



Nevermind, my texts don't talk about friend classes, never even seen it before.... But handy none the less :D Least I won't have to duplicate so much code now.

http://www.cplusplus.com/doc/tutorial/inheritance/

EDIT:

ohh... ok maybe not what I was thinking then.
All I can say at this point is that each symbol should be declared once and only once, in one header file.


so in other words, don't create multiple headers for each class? I will try to explain a bit better.

basically I have my main class by main I mean (int main(), filename: a2Main.cpp) which simply deals with command line arguments and then creates an object of class StringSort(which is a separate file called a2.cpp) and calls StringSort's runApp() method.
Because the dealing with command line arguments in int main is about 100 lines of code, I wanted to stick into a different file, whether or not this has to be a different class has no bearing I don't mind, but I am unsure which.
Last edited on
so is this acceptable?

a2.h :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef A2_H
#define A2_H

#import <string>
using std::string;

class StringSort
{
    public:
      const static int arraySize=100;
      void runApp();
      void inputArray();
      void outputArray();

    private:
      int count;
};

class CheckArgs
{
    public:
      void cmdArgs(int argc,char *argv[]);
      string getIParam;
      string getOParam;

    private:
      string iparam;
      string oparam;
};

#endif  



my main class without all the cmd line junk in it only would contain this:

1
2
3
4
5
6
7

int main(int argc,char *argv[])
{
    StringSort ss();
    ss.runApp();
    return 0;
}
Last edited on
whatevs, I'll just keep testing till something works.
if ... I could actually get something to work :(

I don't get it, I thought I could do that, like the header file above ^^, but when I try and compile the StringSort methods in object file it complains about class CheckArgs in the header file.

Topic archived. No new replies allowed.