I am learning C++, but I ran into an error which I don't understand.
Here is my source code, comments included (personal reference as I am learning.)
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
float h; //a float stands for floating point variable and can hold a number that is a fraction. I.E. 8.5
double j; //a double can hold larger fractional numbers. I.E. 8.24525234
char f; // char stands for character and can hold only one character (converts to ASCII, behind scenes).
f = '$'; //char can hold any common symbol, numbers, uppercase, lowerver, and special characters.
h = "8.5";
j = "8.56";
cout << "J: " << j << endl;
cout << "H: " << h <<endl;
cout << "F: " << f << endl;
cin.get();
return 0;
}
I receive the following errors when compiling:
error C2440: '=' : cannot convert from 'const char [4]' to 'float' There is no context in which this conversion is possible
And
error C2440: '=' : cannot convert from 'const char [5]' to 'double' There is no context in which this conversion is possible
Can you guys point me in the right direction? I just learned about const (20 minutes ago maybe) and I don't understand why this previous program isn't working properly.