| | |
Error C2734: 'Value' : const obje
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I'm new to C++ and I'm studying out of a book (Game Programming - All In One, 2002) From what I've seen from other programs it's sort of out of date. Can someone tel me what's wrong with this?
-Error C2734: 'Value' : const object must be initialized if not extern
(It origionaly used std::cout and std::cin)
#include <iostream>
using namespace std;
main (void)
{
const float Value, FeetPerMeter = Value;
float Length1;
float Length2;
float Length3;
cout << "Enter the first lenght in meters: ";
cin >> Length1;
cout << "Enter the second length in meters: ";
cin >> Length2;
cout << "Enter the third lenght in meters: ";
cin >> Length3;
cout << "First length in feet is: " << Length1 * FeetPerMeter << endl;
cout << "Second length in feet is: " << Length2 * FeetPerMeter << endl;
cout << "Third length in feet is: " << Length3 * FeetPerMeter << endl;
return 0;
}
This is what the book told me to insert, but it even looks incorrect to me. HMM, does anyone know what's wrong with this?
-Error C2734: 'Value' : const object must be initialized if not extern
(It origionaly used std::cout and std::cin)
#include <iostream>
using namespace std;
main (void)
{
const float Value, FeetPerMeter = Value;
float Length1;
float Length2;
float Length3;
cout << "Enter the first lenght in meters: ";
cin >> Length1;
cout << "Enter the second length in meters: ";
cin >> Length2;
cout << "Enter the third lenght in meters: ";
cin >> Length3;
cout << "First length in feet is: " << Length1 * FeetPerMeter << endl;
cout << "Second length in feet is: " << Length2 * FeetPerMeter << endl;
cout << "Third length in feet is: " << Length3 * FeetPerMeter << endl;
return 0;
}
This is what the book told me to insert, but it even looks incorrect to me. HMM, does anyone know what's wrong with this?
"But I'm not a slave to a god that doesn't exist
But I'm not a slave to world that doesn't give a S•••" - Marilyn Manson (The Fight Song)
Well, I put in a number and then it worked not as i planed although. First i enterd the first, then the second, then the third. Then it just shuts the window concole.
"But I'm not a slave to a god that doesn't exist
But I'm not a slave to world that doesn't give a S•••" - Marilyn Manson (The Fight Song)
•
•
•
•
Originally Posted by .·)Tusky(·.
Well, I put in a number and then it worked not as i planed although.
•
•
•
•
Originally Posted by .·)Tusky(·.
First i enterd the first, then the second, then the third. Then it just shuts the window concole.
C++ Syntax (Toggle Plain Text)
cin.get();
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Error in tree insertion (C++)
- link ereror using static const int (C++)
- Const object declaration without default constructor (C++)
- passing `const' as `this' argument of `' discards qualifiers (C++)
- error in copy constructor (C)
- compiling error, tried debugging but no luck (C)
Other Threads in the C++ Forum
- Previous Thread: Unary Operators
- Next Thread: Devanagari Keyboard Program
| Thread Tools | Search this Thread |
api array beginner bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets







.