Help Please

Still having some trouble with my assignment. This is what I have so far.

I have getting these errors:

Error C2447: '{' : missing function header (old-style formal list?)

fatal error C1004: unexpected end-of-file found
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
78
79
80
81
82
83
84
85
86
87
88
89
 /* Programmers full name: Nicholas James Barbella
Today’s Date: July 5th, 2016
Lesson number: 9
Program purpose:Write a C++ code to initialize each component of inventory as follows: part name to null string, partNum to -1, price to 0.0 and quantities in quantitiesInStock to 0. */


#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <conio.h>
#include <stdio.h>


{;

using namespace std;

int main ();

class invalidMonth { ;


public:

    invalidMonth() throw();
    invalidMonth(const exception&) throw();
    invalidMonth& operator=(const exception&) throw();

	class invalidDay { ;


public:
    invalidDay() throw();
    invalidDay(const exception&) throw();
    invalidDay& operator=(const exception&) throw();

 void main()


    int month, day, year;
    cout << "Enter the month" << endl;

    cin >> month;

    cout << "Enter the day" << endl;

    cin >> day;

    cout << "Enter the year" << endl;

    cin >> year;

    cout << "The date is " << day << "-" << month << "-" << year << "." << endl;
    if (day > 31)
        cout << “Invalid Date”;

    if (month == 1)
        cout << "January ";
    else if (month == 2)
        cout << "February ";
    else if (month == 3)
        cout << "March ";
    else if (month == 4)
        cout << "April ";
    else if (month == 5)
        cout << "May ";
    else if (month == 6)
        cout << "June ";
    else if (month == 7)
        cout << "July ";
    else if (month == 8)
        cout << "August ";
    else if (month == 9)
        cout << "September ";
    else if (month == 10)
        cout << "October ";
    else if (month == 11)
        cout << "November ";
    else if (month == 12)
        cout << "December ";
    else
        cout << "Invalid month";


	{

	}
You've already been told how to fix most of these errors:

Line 16: get rid of the {;

Line 20: This is a forward declaration of main(). It's not illegal, but it's not needed.

Line 22: Get rid of the ;

Line 31: Is this supposed to be a nested class? Get rid of the ;

Line 38: You need a }; to terminate the nested invalidDay class.

Line 38.1: You need a }; to terminate the invalidMonth class. If invalidDay is not intended to be a nested class, then this should be at line 30.

Line 39: main() must return type int.

Line 40: You need a { to open the code block for main()

Line 57: Wrong quote marks.

Line 87: Extraneous { Get rid of it.

Not clear what the purpose of your classes is. You don't use them.


Please do not open a new thread for the same problem:
http://www.cplusplus.com/forum/beginner/194928/

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
#include <iostream>
using namespace std;

class invalidMonth 
{ 
public:
    invalidMonth() throw();
    invalidMonth(const exception&) throw();
    invalidMonth& operator=(const exception&) throw();
};

class invalidDay 
{
public:
    invalidDay() throw();
    invalidDay(const exception&) throw();
    invalidDay& operator=(const exception&) throw();
};
    
int main()
{   int month, day, year;
    cout << "Enter the month" << endl;
    cin >> month;

    cout << "Enter the day" << endl;
    cin >> day;

    cout << "Enter the year" << endl;
    cin >> year;

    cout << "The date is " << day << "-" << month << "-" << year << "." << endl;
    if (day > 31)
        cout << "Invalid Date";

    if (month == 1)
        cout << "January ";
    else if (month == 2)
        cout << "February ";
    else if (month == 3)
        cout << "March ";
    else if (month == 4)
        cout << "April ";
    else if (month == 5)
        cout << "May ";
    else if (month == 6)
        cout << "June ";
    else if (month == 7)
        cout << "July ";
    else if (month == 8)
        cout << "August ";
    else if (month == 9)
        cout << "September ";
    else if (month == 10)
        cout << "October ";
    else if (month == 11)
        cout << "November ";
    else if (month == 12)
        cout << "December ";
    else
        cout << "Invalid month";
    return 0;
}

Last edited on
Topic archived. No new replies allowed.