for some reason i get a compile error on the following.
dont know why, this is an example code from my CD that came with my book i got today. it is supost to work as is, without me chanign anything (witch i havent) but when i go to compile it i get the following error
14 c:\docume~1\kida\desktop\programs\conver~1.cpp
`class _IO_ostream_withassign' has no member named `alpha'
what the hell is going on? this code is in the book and the example is off the CD, and it gets compile error? plz plz plz explain this, try compileing it yourself.
all this code does is look at two number input my th euser, and tells you if they are even by stating true or false.
heres the code..
Code:
// BoolTest - compare variables input from the
// keyboard and store the results off
// into a logical variable
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// set output format for bool variables
// to true and false instead
// of 1 and 0
cout.setf(cout.alpha);
// initialize two arguments
int nArg1;
cout << "Input value 1: ";
cin >> nArg1;
int nArg2;
cout << "Input value 2: ";
cin >> nArg2;
bool b;
b = nArg1 == nArg2;
cout << "The statement, " << nArg1
<< " equals " << nArg2
<< " is " << b
<< endl;
// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
The compiler error is saying that the ostream class, which cout is an instance of, doesn't have a member called alpha, which is being used to try to output booleans as the words true or false. Either get a newer version of the iostream classes, or comment out that line.
The compiler error is saying that the ostream class, which cout is an instance of, doesn't have a member called alpha, which is being used to try to output booleans as the words true or false. Either get a newer version of the iostream classes, or comment out that line.
and where might i find a newer version of iostream classes????
Hmm, maybe your compiler doesn't have support for that particular instance. I Remember how conio.h didn't exist in the SciTE compiler I used, as I'd have to use conio_mingw.h instead. It was strange.
Tinker around with things though. Download multiple compilers and try them. Or do like WetWired said, comment out the line.
"Stephen Wolfram is the creator of Mathematica and is widely regarded as the most important innovator in scientific and technical computing today." - Stephen Wolfram
That I couldn't tell you, except to look for a newer version of your C++ standard library package or your toolchain as a whole.
It would be much easier for now to simply comment out that line and use 1 and 0 instead of the words true and false, though if these examples will continue to use the alpha member of cout, getting new libraries may be your only option.