Car Class

I'm not sure if my program is working or not, but I've been having trouble with the compiler. :/

"Source file not compiled"

I reinstalled it and same response. :/

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
#include <iostream>

using namespace std;

const int MAX = 60;

struct Car
{
char make[MAX];      
       
int    year, brake, accel, speed;
       
       Car set_info()
       {
              Car set = {"New Model", 0000, 0, 0, 0};
    
              return(set);
       }
};

void getCar(Car &data);
void showCar(Car data);

int main ()
{
Car data;   

getCar(data);
showCar(data);

cout << "\n\n\n";

system ("pause"); 
return 0;
}
void getCar(Car &data)
{
            cout << "Enter the name of the vechile: ";
            cin.getline(data.make, MAX);
            
            cout << "\nEnter the year model (4-digits): ";
            cin >> data.year;

            cout << "\n\n";
}
void showCar(Car data)
{
     int speed = 0, fast, slow, go, stop;

              fast = speed + 5;
              go *= fast;
              
              slow = speed - 5;
              stop *= slow;
         
            cout << "The model of the vechile is " << data.make << ".\n";
            cout << "The year of the vechile is " << data.year << ".\n";
            cout << "The vechile accelerated fives at a set speed of " << go << ".\n";
            cout << "The vechile brake fives at a set speed of " << stop << ".\n";
}
In Visual Studio, Windows, this program compiles and runs fine (disregarding runtime bugs). What do you mean by reinstalling it? Did you compile and build the executable? Are you getting any specific compiler warnings or errors?
Last edited on
I'm using Dev C++ from Bloodshed and I had a portable version of it as well; however, it states that my source file isn't compiled despite the fact I compiled it.
Only solution I can think of with information I get is to start a new project from scratch, with new name and location. Often it is easier than trying to figure out why the IDE is revolting.

As a complete sidenote, please note, the Bloodshed version of Dev C++ (4.9.9.2) is outdated to the extend that DOES matter and may be a pain for beginer programmer in 2013/14 - almost 9 years after this realease was published. Consider updatting to Orwell's Dev C++, Code::Blocks, or MS Visual C++ - which are all great and free IDEs.
Last edited on
Thanks. I did what ya said, "new name and location" and it worked. Kinda figured as much, the Dev C++ is great, but it bugs out too much. I'll try to get my hands on it.

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
#include <iostream>

using namespace std;

const int MAX = 60;

struct Car
{
char   make[MAX];      
       
int    year, brake, accel, speed;
};

void getCar(Car &data);
void showCar(Car data);

int main ()
{
Car data;   

getCar(data);
showCar(data);

cout << "\n\n\n";

system ("pause"); 
return 0;
}
void getCar(Car &data)
{
            cout << "Enter the name of the vechile: ";
            cin.getline(data.make, MAX);
            
            cout << "\nEnter the year model (4-digits): ";
            cin >> data.year;
            
            while((data.year < 1000) || (data.year > 9999))
            {
                    cout << "\nInvalid Input. Enter 4-digits for the modeled year: ";
                    cin >> data.year;           
            }

            cout << "\n\n";
}
void showCar(Car data)
{
     int speed = 0, fast, slow, go, stop;

              fast = speed + 5;
              go = fast * fast;
              
              slow = speed - 5;
              stop = slow * slow;
         
            cout << "The model of the vechile is " << data.make << ".\n";
            cout << "The year of the vechile is " << data.year << ".\n";
            cout << "The vechile accelerated fives times at a set speed of " << go << ".\n";
            cout << "The vechile brake fives times at a set speed of -" << stop << ".\n";
}
Topic archived. No new replies allowed.