IntelliSense: expession must have integral or unscoped enum type

So far I have the following code:

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
// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
# include <string>
using namespace std;

int main()
{
	float X = 10;

	string Y="";
	
	X = 5, 7, 10;

	cout << X << endl; 
	cout << "Enter the number of the desired year\n"
		<< "tells you the number of millemeters the current ocean level is.: ";
	getline(cin, Y);
	cin >> Y;

	cout << "The number of millimeters higher the current level of the ocean in 5 years is; " << Y = X * 1.5 << '.' << endl;
	
	cout << "The number of millimeters higher the current level of the ocean in 7 years is; " << Y = X * 1.5 << '.' << endl;
	
	cout << "The number of millimeters higher the current level of the ocean in 10 years is; " << Y = X * 1.5 << '.' << endl;
	cin >> Y;

	cout << "Press the Enter key to continue...";
	cin.get();
	return 0;
}	//end main() 


, but I get the following error message:

IntelliSense: expession must have integral or unscoped enum type

three times in a row for lines 25, 27, and 29 and I don't understand or know why?

In case the purpose does make sense here are the directions:

2.7: Ocean Levels
Assuming the ocean’s level is currently rising at about 1.5 millimeters per year, write a program that displays
• The number of millimeters higher than the current level that the ocean’s level will be in 5 years,
• The number of millimeters higher than the current level that the ocean’s level will be in 7 years,
• The number of millimeters higher than the current level that the ocean’s level will be in 10 years,

Output labels: Each value should be on a line by itself, preceded by the a label of the form:
In X years the ocean's level will be higher by Y millimeters.
where X is the number of years (5, 7 or 10) and Y is the value you calculate.


Does any else have an idea?
Last edited on
This is probably not doing what you're expecting it too. X will only hold one value, not three.

X = 5, 7, 10;

You're trying to do an assignment to Y within the three output statements. I'm guessing you didn't mean to try to overwrite the year which the user entered in Y. What are you trying to output here?

cout << "The number of millimeters higher the current level of the ocean in 5 years is; " << Y = X * 1.5 << '.' << endl;

If you edit your post, highlight the code part, then click on the <> button in the Format palette at the right of the post, your code will format for the forum with line numbers etc.
Last edited on
What your saying is that I can't assign X three values, but I can assign X to multiple assignments?

Also where am I trying to do an assignment to Y within the three output statements and overwrite the year, which the user entered in Y?
Output labels: Each value should be on a line by itself, preceded by the a label of the form:
In X years the ocean's level will be higher by Y millimeters.
where X is the number of years (5, 7 or 10) and Y is the value you calculate.


Quit thinking of X and Y as variables. They are simply place holders in the text of the problem description to indicate where certain values should be displayed in the output. They don't necessarily have any place in the code as variables.

You have defined Y as a string and X as a float. The expression Y = X * 1.5 is nonsensical to the compiler. If you're using C++11, you could use Y = std::to_string(X * 1.5) to get it to compile, however the assignment to string isn't necessary because our std::ostream handles the display of floating point values just fine:
cout << "The number ... is: " << X*1.5 << ".\n";
I know it says expression must have integral or unscoped enum type, but what does that mean? Also I tried a scoped enum as follows, but it didn't like it either:

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
// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
using namespace std;

int main()
{
	int Y;
	int yearValue; // To hold year number desired.
	enum year { X=5, X2=7, X3=10};
	

	Y = (yearValue + X) * 1.5;
	Y = (yearValue + X2) * 1.5;
	Y = (yearValue + X3) * 1.5;

	cout << "Enter the current year";
	cin >> yearValue;
	cout << "The number of millimeters higher the current level of the ocean in 5 years is; " << Y = (yearValue + X) * 1.5 << '.' << endl;
	cout << "The number of millimeters higher the current level of the ocean in 7 years is; " << Y = (yearValue + X2) * 1.5 << '.' << endl;
	cout << "The number of millimeters higher the current level of the ocean in 10 years is; " << Y = (yearValue + X3) * 1.5 << '.' << end;

	cout << "Press the Enter key to continue...";
	cin.get ();
	return 0;
}	//end main() 
Last edited on
You're overwriting the value of Y here each time you make a new assignment. And yearValue won't have a value yet since the user doesn't input the year until after this code.

1
2
3
Y = (yearValue + X) * 1.5;
Y = (yearValue + X2) * 1.5;
Y = (yearValue + X3) * 1.5;


The code still has this assignment statement in the output stream. (assignment meaning the code is doing a calculation and trying to assign it to Y.)

<< Y = (yearValue + X) * 1.5 <<


I might do something like this - I've just put one option here for 5 years, but it would be similar for the other years. Using a constant variable instead of hardcoding the specific number makes it easier later on to change the time periods without having to search through the code to update in multiple places. This is a short program, so it's not a big deal here, but just something to keep in mind.

You might also want to add in some validation to make sure that they've input a valid year.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# include <iostream>
using namespace std;

int main()
{
    const int periodA = 5;
    int year = 0;
    
    cout << "Enter the current year: ";
    cin >> year;
    cout << "In " << periodA << " years, the ocean will be " << (year + periodA) * 1.5 << " millimeters higher than its current level." << endl;

    cout << "Press the Enter key to continue...";
    cin.get ();
    return 0;
}

I solved a few problems but aquired some more unless they already existed. My current source code is as follows:

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
// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
# include <string>
using namespace std;

int main()
{
	string YearValue(); // fixes error with illegal operand on + symbol
	int leap(double X1, double X2, double X3, double Y1, double Y2, double Y3);
	int count(int YearVariable);
	double X1 = 5; // fixes error with X1 not defined
	double X2 = 7; // fixes error with X2 not defined
	double X3 = 10; // fixes error with X3 not defined
	double Y1 = (YearValue + X1) * 1.5; // fixes error with Y1 not defined
	double Y2 = (YearValue + X2) * 1.5; // fixes error with Y2 not defined
	double Y3 = (YearValue + X3) * 1.5; // fixes error with Y3 not defined
	
	enum year { X1 = 5, X2 = 7, X3 = 10 }; // fixes error with expression must have integral or unscoped enum type.
	enum millhigher {Y1 =  (YearValue + X1) * 1.5 const , Y2 = (YearValue + X2) * 1.5 const, Y3 = (YearValue + X3) * 1.5 const } ; // fixes
	//				error with expression must have integral or unscoped enum type.

	cout << "Enter the current year: ";
	cin >> YearValue;
	cout << "The number of millimeters higher the current level of the ocean in" << X1 << "years will be " << Y1 << '.' << endl; // prints output
	cout << "The number of millimeters higher the current level of the ocean in" << X2 << "years will be" << Y2 << '.' << endl; // prints output
	cout << "The number of millimeters higher the current level of the ocean in" << X3 << "years will be" << Y3 << '.' << endl; // prints output

	cout << "Press the Enter key to continue..."; // ends program
	cin.get (); //verbose or display output on screen by talking in text to user.
	return 0;
}	//end main() 
Any idea how to solve the following errors:

35 IntelliSense: no operator ">>" matches these operands
operand types are: std::istream >> std::string () c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 28 6 Project5
30 IntelliSense: expression must have integral or unscoped enum type c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 19 27 Project5
31 IntelliSense: expression must have integral or unscoped enum type c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 20 27 Project5
32 IntelliSense: expression must have integral or unscoped enum type c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 21 27 Project5
33 IntelliSense: expression must have a constant value c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 24 38 Project5
34 IntelliSense: expected a '}' c:\Users\dgrossi0914\Documents\Visual Studio 2013\Projects\Program2\Project5\Project5\Source.cpp 24 48 Project5
Error 9 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 24 1 Project5
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 25 1 Project5
Error 13 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 26 1 Project5
Error 16 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 27 1 Project5
Error 19 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 28 1 Project5
Error 22 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 30 1 Project5
Error 25 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 31 1 Project5
Error 6 error C2365: 'X3' : redefinition; previous definition was 'data variable' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 21 1 Project5
Error 5 error C2365: 'X2' : redefinition; previous definition was 'data variable' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 21 1 Project5
Error 4 error C2365: 'X1' : redefinition; previous definition was 'data variable' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 21 1 Project5
Error 1 error C2296: '+' : illegal, left operand has type 'std::string (__cdecl *)(void)' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 17 1 Project5
Error 2 error C2296: '+' : illegal, left operand has type 'std::string (__cdecl *)(void)' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 18 1 Project5
Error 3 error C2296: '+' : illegal, left operand has type 'std::string (__cdecl *)(void)' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 19 1 Project5
Error 10 error C2143: syntax error : missing ';' before '>>' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 25 1 Project5
Error 8 error C2143: syntax error : missing ';' before '<<' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 24 1 Project5
Error 12 error C2143: syntax error : missing ';' before '<<' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 26 1 Project5
Error 15 error C2143: syntax error : missing ';' before '<<' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 27 1 Project5
Error 18 error C2143: syntax error : missing ';' before '<<' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 28 1 Project5
Error 21 error C2143: syntax error : missing ';' before '<<' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 30 1 Project5
Error 29 error C2143: syntax error : missing ';' before '}' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 33 1 Project5
Error 24 error C2143: syntax error : missing ';' before '.' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 31 1 Project5
Error 14 error C2086: 'int cout' : redefinition c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 26 1 Project5
Error 17 error C2086: 'int cout' : redefinition c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 27 1 Project5
Error 20 error C2086: 'int cout' : redefinition c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 28 1 Project5
Error 23 error C2086: 'int cout' : redefinition c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 30 1 Project5
Error 26 error C2086: 'int cin' : redefinition c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 31 1 Project5
Error 7 error C2062: type 'double' unexpected c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 22 1 Project5
Error 27 error C2059: syntax error : 'return' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 32 1 Project5
Error 28 error C2059: syntax error : '}' c:\users\dgrossi0914\documents\visual studio 2013\projects\program2\project5\project5\source.cpp 33 1 Project5
You've defined YearValue to be a function that returns a string on line 10.

string YearValue();

But then you try to add YearValue as if it were a variable. But if YearValue is a string and X1 is a double, you can't add those. Also - the user hasn't entered a value for the year at this point, so Y1 is not going to end up having a valid value.

double Y1 = (YearValue + X1) * 1.5;

The program is run through line by line sequentially - a later line in the code is not going to look back to this definition at the beginning of main to recalculate what Y1 should be when you try to cout the value.

You don't need the enum lines. You really don't even need the Y variables. You can output the value of the calculation (year+increment) * 1.5 directly.
First, quit paying attention to Intellisense messages. They're helpful if you know what you're doing, but you clearly do not. Instead, pay attention to errors generated when you actually attempt to compile. (Use the Output tab as opposed to the Error List tab, and choose Show output from Build.)

You need to revisit your specification. There is no requirement for you to ask the user for a year.

Lines 10, 11 and 12 in your code declare functions which are never defined.
Lines 16, 17 and 18 attempt to do pointer arithmetic with a function pointer. This is an error.
On line 20 you attempt to re-define identifiers already defined in the current scope. This is an error.
On line 21 you attempt to do pointer arithmetic with a function pointer. This is an error.

You're really over-thinking this.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

int main()
{
    double yearly_rate = 1.5;

    const char* the_number_in = "The number of millimeters higher the level of the ocean will be in ";
    const char* years_is = " years is: ";

    std::cout << the_number_in << 5 << years_is << 5 * yearly_rate << '\n';
    std::cout << the_number_in << 7 << years_is << 7 * yearly_rate << '\n';
    std::cout << the_number_in << 10 << years_is << 10 * yearly_rate << '\n';
}




You've defined YearValue to be a function that returns a string on line 10.

"string YearValue();

But then you try to add YearValue as if it were a variable. But if YearValue is a string and X1 is a double, you can't add those. Also - the user hasn't entered a value for the year at this point, so Y1 is not going to end up having a valid value.

double Y1 = (YearValue + X1) * 1.5;

The program is run through line by line sequentially - a later line in the code is not going to look back to this definition at the beginning of main
Edit & Run
to recalculate what Y1 should be when you try to cout the value.

You don't need the enum lines. You really don't even need the Y variables. You can output the value of the calculation (year+increment) * 1.5 directly."

I know you said I don't need the enum lines, but I couldn't figure out a way to get it to work with it for the X variable. However, I did get it to work without a Y variable as follows:

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
// Purpose: To write a program that displays the number of millimeters higher the current level the ocean level will be in
// in 5, 7, and 10 years.

# include <iostream>
using namespace std;

int main()
{
	double yearly_rate = 1.5;
	double YearValue;
	
	enum year { X1 = 5, X2 = 7, X3 = 10 }; // fixes error with expressiona must have integral or unscoped enum type.

	cout << "Enter the current year: ";
	cin >> YearValue;
	cout << "The number of millimeters higher the current level of the ocean in " << X1 << " years will be " << (YearValue + X1) * yearly_rate - (YearValue * yearly_rate) << '.' << endl; // prints output
	cout << endl << "It has paused. Press Enter to continue. ";
	YearValue = cin.get();
	cout << "The number of millimeters higher the current level of the ocean in " << X2 << " years will be " << (YearValue + X2) * yearly_rate - (YearValue * yearly_rate) << '.' << endl; // prints output
	cout << endl << "It has paused a second time. Press Enter to continue. ";
	YearValue = cin.get();
	cout << "The number of millimeters higher the current level of the ocean in " << X3 << " years will be " << (YearValue + X3) * yearly_rate - (YearValue * yearly_rate) << '.' << endl; // prints output
	cout << "Here the program is paused a third time, ";
	cin.get();

	cout << "Press the Enter key to continue..."; // ends program
	cin.get(); //verbose or display output on screen by talking in text to user.
	return 0;
}	//end main() 
Last edited on
This really isn't a situation where I'd use enums.

See Cire's post above for an even more simplified approach.
"First, quit paying attention to Intellisense messages. They're helpful if you know what you're doing, but you clearly do not. Instead, pay attention to errors generated when you actually attempt to compile. (Use the Output tab as opposed to the Error List tab, and choose Show output from Build.)

You need to revisit your specification. There is no requirement for you to ask the user for a year.

Lines 10, 11 and 12 in your code declare functions which are never defined.
Lines 16, 17 and 18 attempt to do pointer arithmetic with a function pointer. This is an error.
On line 20 you attempt to re-define identifiers already defined in the current scope. This is an error.
On line 21 you attempt to do pointer arithmetic with a function pointer. This is an error.

You're really over-thinking this.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

int main()
{
double yearly_rate = 1.5;

const char* the_number_in = "The number of millimeters higher the level of the ocean will be in ";
const char* years_is = " years is: ";

std::cout << the_number_in << 5 << years_is << 5 * yearly_rate << '\n';
std::cout << the_number_in << 7 << years_is << 7 * yearly_rate << '\n';
std::cout << the_number_in << 10 << years_is << 10 * yearly_rate << '\n';"

This had build errors and doesn't take any input as far as I can tell, so for now I'm sticking with the source code in my previous reply.
Last edited on
This had build errors and doesn't take any input as far as I can tell, so for now I'm sticking with the source code in my previous reply.


Cire's code works OK for me - there's a little gear icon at the top right of the code that lets you run the code from the forum - see if that works for you?

Does the assignment (other than what you've posted here) tell you that the user has to enter the year? If it's being based off the current year, you know what that is, the user doesn't have to input it.

Even if the user should be able to input the year, I still don't think this is a case where enums are called for.
Cire your code does work if I do the following, but whether its the correct answer remains to be seen. However, if it makes you feel any better nether was mine as you pretty much predicted in your response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;

	int main()
{
		double yearly_rate = 1.5;

		const char* the_number_in = "The number of millimeters higher the level of the ocean will be in ";
		const char* years_is = " years is: ";

		std::cout << the_number_in << 5 << years_is << 5 * yearly_rate << '\n';
		std::cout << the_number_in << 7 << years_is << 7 * yearly_rate << '\n';
		std::cout << the_number_in << 10 << years_is << 10 * yearly_rate << '\n';
		std::cout << "Press the Enter key to continue..."; // ends program
cin.get(); //verbose or display output on screen by talking in text to user.
return 0;
}	//end main() 
Unfortunately Cire it was still not the correct answer, but it was the best answer yet.
With some help from another source I was able to solve it with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main()
{
	double fiveYears, sevenYears, tenYears;

	fiveYears = 5 * 1.5;
	sevenYears = 7 * 1.5;
	tenYears = 10 * 1.5;


	cout << "In 5 years the ocean's level will be higher by " << fiveYears << " millimeters." << endl;
	cout << "In 7 years the ocean's level will be higher by " << sevenYears << " millimeters." << endl;
	cout << "In 10 years the ocean's level will be higher by " << tenYears << " millimeters." << endl;

	cin.get();
	return 0;
}



It is extremely picky though and did not like my use of the following line either:

cout << "Press the Enter key to continue..."; // ends program

,but didn't mind my use of the following:

cin.get();

Thanks for everyone's help with this problem

Topic archived. No new replies allowed.