Error when multiplying

This is the error I am getting.
Severity Code Description Project File Line
Error (active) no operator "*" matches these operands Variables c:\Users\mumin\Documents\Visual Studio 2015\Projects\Variables\Source.cpp 12


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

using namespace std;

int main()
{
	string str = "Hello World!";

    cout << str << endl;

	float dec = 5.0f * str << endl;

	int integer = 65;

	cout << "Integer = " << integer << endl;
}


I was trying to fix this original code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include #include 

int mian ( )
{
 string str = "Hello World!"

 cout << str << endl;

 cout << float x = 5.0f * str << end;

 int 65Num = 65;

 cout << "65Num = " < 65Num << endl;
}
Last edited on
closed account (48T7M4Gy)
float dec = 5.0f * str << endl;

What's that mean? That's where your error is - you are multiplying a string by something.
Last edited on
How do i fix it.
closed account (48T7M4Gy)
You may as well delete the line.
How do i fix it.
What are you trying to do there?

By the way: a variable name must not start with a number.
Its for an assignment. I have to fix this code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include #include 

int mian ( )
{
 string str = "Hello World!"

 cout << str << endl;

 cout << float x = 5.0f * str << end;

 int 65Num = 65;

 cout << "65Num = " < 65Num << endl;
}
What are you trying to achieve with that line? Why are you trying to multiply a string by a number?
Topic archived. No new replies allowed.