Program is not Outputting =\

I'm currently working on a school project in which I have to create a class for this client program. I commented out all the code I'm not currently using to test each bit by bit as I create the class bit by bit. When I compile and run the program, the cout statements don't output to the screen. All that appears is "Press any Key to continue..." Any help would be appreciated.

This has never happened until today so I'm stumped as to what the problem could be.

Update: When I run any other previous CPP I have it runs just fine, it's only this file that seems to have trouble showing any output.
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include "fraction.h"
using namespace std;

int main()
{
    fraction f1(9,8); //calling a parameterized class constructor
    fraction f2(2,3); //calling a parameterized class constructor
    fraction result;  //calling a default class constructor
    fraction f3; //calling a default class constructor

    cout << "The result starts off at ";
    result.print(); //calling an observer function
    cout << endl;

    /*cout << "The product of ";
    f1.print();
    cout << " and ";
    f2.print();
    cout << " is ";
    result = f1.MultipliedBy(f2); //a class binary operation - function
    result.print();
    cout << endl;
    
    f3 = result; //assignment 
    
     if (f2.isGreaterThan(f3)){ //a class relational expression - boolean operation/function
        f2.print();
        cout <<" is greater than ";
        f3.print();
        cout<<endl;
    } else {
        f2.print();
        cout <<" is less than ";
        f3.print();
        cout<<endl;
    }

    cout << "The sum of ";
    f1.print();
    cout << " and ";
    f2.print();
    cout << " is ";
    result = f1.AddedTo(f2); //a class binary operation - function
    result.print();
    cout << endl;

    cout << "The difference of ";
    f1.print();
    cout << " and ";
    f2.print();
    cout << " is ";
    result = f1.Subtract(f2); //a class binary operation - function
    result.print();
    cout << endl;

    if (f1.isEqualTo(f2)){ //a class relational expression - boolean operation/function
        cout << "The two fractions are equal." << endl;
    } else {
        cout << "The two fractions are not equal." << endl;
    }
    
    const fraction f4(12, 8);
    const fraction f5(202, 303);

    result = f4.DividedBy(f5); //a class binary operation - function
    cout << "The quotient of ";
    f4.print();
    cout << " and ";
    f5.print();
    cout << " is ";
    result.print();
    cout << endl; */

    system ("PAUSE");//exclude statement if not using Dev-C++
    return 0;
}
Last edited on
Have you run it through a debugger to follow the execution?

If not, try adding a cout call as the first statement; then you'll find out whether your code is doing anything before exiting.

You don't have an exit call in the fraction class constructor, do you?
Last edited on
I am running it through a debugger and nothing is showing up out of the ordinary.

As for the cout call in the first statement, I did that and same thing, so nothing is happening with the code.
Last edited on
Trying sticking fhrughruehgue in as the first line and check that it fails to compile.
So the debugger steps through the whole code?

You've not got the output redirected to the 'console' output window (or similar) within your development environment, have you?
jim80y (8) Nov 8, 2011 at 4:15pm
So the debugger steps through the whole code?

You've not got the output redirected to the 'console' output window (or similar) within your development environment, have you?


How would I check for that? I dont think I have, I opened a new blank project file in Dev-C++ and went from there.
Moschops (1549) Nov 8, 2011 at 4:13pm
Trying sticking fhrughruehgue in as the first line and check that it fails to compile.


It failed to compile, gave me the generic no ; error among others
Just checking; it wouldn't have been the first time that someone's compiler wasn't actually compiling the code they thought it was.
How would I check for that? I dont think I have, I opened a new blank project file in Dev-C++ and went from there.


I'm not familiar with Dev-C++ - (it may not even have that option, AFAIK) but it'll be in either the project settings or the environment settings somewhere.

You could try running it outside of Dev-C++, see whether you get output then.
Ok so the problem is with Dev-C++, exacltly the problem, I still don't know
Uninstalling and Reinstalling didn't work either
When I run any other previous CPP I have it runs just fine, it's only this file that seems to have trouble showing any output.
You don't have an exit call in the fraction class constructor, do you?


I don't think so, I only have constructors, functions and 2 declarations
Topic archived. No new replies allowed.