Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes

 
Evil Grin Compile error?! Explain somone plz. "Example code of a CD, unchanged"
Reply
Posted 2004-08-04, 01:35 AM
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; 
}
Old
Profile PM WWW Search
Kidagakash is neither ape nor machine; has so far settled for the in-betweenKidagakash is neither ape nor machine; has so far settled for the in-between
 
 
Kidagakash
 



 
Reply
Posted 2004-08-04, 06:41 AM in reply to Kidagakash's post "Compile error?! Explain somone plz...."
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.
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 



 
Reply
Posted 2004-08-04, 04:23 PM in reply to WetWired's post starting "The compiler error is saying that the..."
WetWired said:
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????
Old
Profile PM WWW Search
Kidagakash is neither ape nor machine; has so far settled for the in-betweenKidagakash is neither ape nor machine; has so far settled for the in-between
 
 
Kidagakash
 



 
Reply
Posted 2004-08-04, 05:03 PM in reply to Kidagakash's post starting "and where might i find a newer version..."
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
Old
Profile PM WWW Search
Chruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed it
 
 
Chruser
 



 
Reply
Posted 2004-08-04, 08:10 PM in reply to Kidagakash's post starting "and where might i find a newer version..."
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.
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 07:15 PM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.