'cout' Undeclared (first Use This Function)

  • (2 Pages)
  • +
  • 1
  • 2

28 Replies - 52453 Views - Last Post: 04 November 2009 - 11:52 AM Rate Topic: -----

#16 Xing   User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: 'cout' Undeclared (first Use This Function)

Posted 01 September 2007 - 09:24 PM

Change ostream to iostream and cout>> to cout<<
Was This Post Helpful? 0
  • +
  • -

#17 PaiN KilleR   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 01-September 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 07:03 AM

ok i changed those things (lol stupid errors :S) now i'm getting those warnings and this error...

warning C4551: function call missing argument list
error C2568: 'identifier' : unable to resolve function overload
warning C4551: function call missing argument list
warning C4551: function call missing argument list
warning C4551: function call missing argument list
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
warning C4551: function call missing argument list
warning C4551: function call missing argument list

"warning C4551: function call missing argument list" came up when i put some
endl;
in my code...

This post has been edited by PaiN KilleR: 02 September 2007 - 07:04 AM

Was This Post Helpful? 0
  • +
  • -

#18 Xing   User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 07:19 AM

Post your changed code.
Was This Post Helpful? 0
  • +
  • -

#19 PaiN KilleR   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 01-September 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 07:31 AM

// MoyProf(guylaine).cpp
// Programmé par: Pascal Martineau
// 1er Septembre 2007
// But: Calculer la moyenne suite au test de Conners   (pas sur ici !!!)
#include <iostream>
using namespace std;

	 float QProf1, QProf2, QProf3, QProf4, QProf5, QProf6, QProf7, QProf8, QProf9, QProf10, QProf11, QProf12;
	 float QProf13, QProf14, QProf15, QProf16, QProf17, QProf18, QProf19, QProf20, QProf21, QProf22, QProf23, QProf24;
	 float QProf25, QProf26, QProf27, QProf28, MoyAProf, MoyBProf, MoyCProf;

int main ()
{

	cout<<"Vous pourrez ici entrez le score (0 à 3) du Client/Patient pour les questions de 1 à 28 inclusivement.";
	endl;
	endl;

	cout<<"Question numéro 1";
	cin>>QProf1;
	cout<<"Question numéro 2";
	cin>>QProf2;
	cout<<"Question numéro 3";
	cin>>QProf3;
	cout<<"Question numéro 4";
	cin>>QProf4;
	cout<<"Question numéro 5";
	cin>>QProf5;
	cout<<"Question numéro 6";
	cin>>QProf6;
	cout<<"Question numéro 7";
	cin>>QProf7;
	cout<<"Question numéro 8";
	cin>>QProf8;
	cout<<"Question numéro 9";
	cin>>QProf9;
	cout<<"Question numéro 10";
	cin>>QProf10;
	cout<<"Question numéro 11";
	cin>>QProf11;
	cout<<"Question numéro 12";
	cin>>QProf12;
	cout<<"Question numéro 13";
	cin>>QProf13;
	cout<<"Question numéro 14";
	cin>>QProf14;
	cout<<"Question numéro 15";
	cin>>QProf15;
	cout<<"Question numéro 16";
	cin>>QProf16;
	cout<<"Question numéro 17";
	cin>>QProf17;
	cout<<"Question numéro 18";
	cin>>QProf18;
	cout<<"Question numéro 19";
	cin>>QProf19;
	cout<<"Question numéro 20";
	cin>>QProf20;
	cout<<"Question numéro 21";
	cin>>QProf21;
	cout<<"Question numéro 22";
	cin>>QProf22;
	cout<<"Question numéro 23";
	cin>>QProf23;
	cout<<"Question numéro 24";
	cin>>QProf24;
	cout<<"Question numéro 25";
	cin>>QProf25;
	cout<<"Question numéro 26";
	cin>>QProf26;
	cout<<"Question numéro 27";
	cin>>QProf27;
	cout<<"Question numéro 28";
	cin>>QProf28;
	endl;
	endl;

	MoyAProf= (QProf4 + QProf5 + QProf6 + QProf10 + QProf11 + QProf12 + QProf23 + QProf27) / 8.0;
	MoyBProf= (QProf1 + QProf2 + QProf3 + QProf8 + QProf14 + QProf15 + QProf16) / 7.0;
	MoyCProf= (QProf7 + QProf9 + QProf18 + QProf20 + QProf21 + QProf22 + QProf26 + QProf28) / 8.0;

	cout<<"Le patient a obtenu une moyenne de :",MoyAProf,"pour la section A";
	cout<<"Le patient a obtenu une moyenne de :",MoyBProf,"pour la section B";
	cout<<"Le patient a obtenu une moyenne de :",MoyCProf,"pour la section C";
	endl;
	endl;
 
}

Was This Post Helpful? 0
  • +
  • -

#20 Bench   User is offline

  • D.I.C Lover
  • member icon

Reputation: 944
  • View blog
  • Posts: 2,464
  • Joined: 20-August 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 08:21 AM

You can't put endl; just on its own. the endl identifier must be used in conjunction with an output stream (e,g, cout is an output stream). Try this instead

 cout << endl; 



Be aware that you can 'chain' together your output, so the following is allowed, by placing the << operator between each element
 cout << "some text" << endl << endl; 

This post has been edited by Bench: 02 September 2007 - 08:22 AM

Was This Post Helpful? 1

#21 PaiN KilleR   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 01-September 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 08:33 AM

// MoyProf(guylaine).cpp
// Programmé par: Pascal Martineau
// 1er Septembre 2007
// But: Calculer la moyenne suite au test de Conners   (pas sur ici !!!)
#include <iostream>
using namespace std;

	 float QProf1, QProf2, QProf3, QProf4, QProf5, QProf6, QProf7, QProf8, QProf9, QProf10, QProf11, QProf12;
	 float QProf13, QProf14, QProf15, QProf16, QProf17, QProf18, QProf19, QProf20, QProf21, QProf22, QProf23, QProf24;
	 float QProf25, QProf26, QProf27, QProf28, MoyAProf, MoyBProf, MoyCProf;

int main ()
{

	cout<<"Vous pourrez ici entrez le score (0 à 3) du Client/Patient pour les questions de 1 à 28 inclusivement." <<endl<<endl;

	cout<<"Question numéro 1";
	cin>>QProf1;
	cout<<"Question numéro 2";
	cin>>QProf2;
	cout<<"Question numéro 3";
	cin>>QProf3;
	cout<<"Question numéro 4";
	cin>>QProf4;
	cout<<"Question numéro 5";
	cin>>QProf5;
	cout<<"Question numéro 6";
	cin>>QProf6;
	cout<<"Question numéro 7";
	cin>>QProf7;
	cout<<"Question numéro 8";
	cin>>QProf8;
	cout<<"Question numéro 9";
	cin>>QProf9;
	cout<<"Question numéro 10";
	cin>>QProf10;
	cout<<"Question numéro 11";
	cin>>QProf11;
	cout<<"Question numéro 12";
	cin>>QProf12;
	cout<<"Question numéro 13";
	cin>>QProf13;
	cout<<"Question numéro 14";
	cin>>QProf14;
	cout<<"Question numéro 15";
	cin>>QProf15;
	cout<<"Question numéro 16";
	cin>>QProf16;
	cout<<"Question numéro 17";
	cin>>QProf17;
	cout<<"Question numéro 18";
	cin>>QProf18;
	cout<<"Question numéro 19";
	cin>>QProf19;
	cout<<"Question numéro 20";
	cin>>QProf20;
	cout<<"Question numéro 21";
	cin>>QProf21;
	cout<<"Question numéro 22";
	cin>>QProf22;
	cout<<"Question numéro 23";
	cin>>QProf23;
	cout<<"Question numéro 24";
	cin>>QProf24;
	cout<<"Question numéro 25";
	cin>>QProf25;
	cout<<"Question numéro 26";
	cin>>QProf26;
	cout<<"Question numéro 27";
	cin>>QProf27;
	cout<<"Question numéro 28";
	cin>>QProf28;
	cout << endl <<endl;

	MoyAProf= (QProf4 + QProf5 + QProf6 + QProf10 + QProf11 + QProf12 + QProf23 + QProf27) / 8.0;
	MoyBProf= (QProf1 + QProf2 + QProf3 + QProf8 + QProf14 + QProf15 + QProf16) / 7.0;
	MoyCProf= (QProf7 + QProf9 + QProf18 + QProf20 + QProf21 + QProf22 + QProf26 + QProf28) / 8.0;

	cout<<"Le patient a obtenu une moyenne de :",MoyAProf,"pour la section A";
	cout<<"Le patient a obtenu une moyenne de :",MoyBProf,"pour la section B";
	cout<<"Le patient a obtenu une moyenne de :",MoyCProf ,"pour la section C" << endl << endl;
 
}


now i have this... and i'm getting... those errors/warnings

------ Build started: Project: MoyProf(guylaine), Configuration: Debug Win32 ------
Compiling...
MoyProf(guylaine).cpp
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
error C2563: mismatch in formal parameter list
error C2568: '<<' : unable to resolve function overload
c:\program files\microsoft visual studio 8\vc\include\ostream(971): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
with
[
_Elem=wchar_t,
_Traits=std::char_traits<wchar_t>
]
c:\program files\microsoft visual studio 8\vc\include\ostream(963): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program files\microsoft visual studio 8\vc\include\ostream(937): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
Build log was saved at "file://c:\Documents and Settings\Pascal\Mes documents\Visual Studio 2005\Projects\MoyProf(guylaine)\MoyProf(guylaine)\Debug\BuildLog.htm"
MoyProf(guylaine) - 2 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#22 Bench   User is offline

  • D.I.C Lover
  • member icon

Reputation: 944
  • View blog
  • Posts: 2,464
  • Joined: 20-August 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 09:01 AM

That looks to be down to these 3 lines
	cout<<"Le patient a obtenu une moyenne de :",MoyAProf,"pour la section A";
	cout<<"Le patient a obtenu une moyenne de :",MoyBProf,"pour la section B";
	cout<<"Le patient a obtenu une moyenne de :",MoyCProf ,"pour la section C" << endl << endl;



Specifically, the comma's which seperate your output. Again, if you want to chain your output statements, you need to use <<

So, the first of those 3 lines will look like this -

cout<<"Le patient a obtenu une moyenne de :" << MoyAProf << "pour la section A";
Was This Post Helpful? 0
  • +
  • -

#23 PaiN KilleR   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 01-September 07

Re: 'cout' Undeclared (first Use This Function)

Posted 02 September 2007 - 09:07 AM

lol thx dude !
Was This Post Helpful? 0
  • +
  • -

#24 Tomas   User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 34
  • Joined: 12-June 07

Re: 'cout' Undeclared (first Use This Function)

Posted 05 September 2007 - 02:03 PM

Hi,

You have forgotten to add the line
using namespace std;

before int main()
Was This Post Helpful? 0
  • +
  • -

#25 Amadeus   User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 250
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: 'cout' Undeclared (first Use This Function)

Posted 05 September 2007 - 02:05 PM

In the last posted code by the user, the namespace identifier is clearly there.
Was This Post Helpful? 0
  • +
  • -

#26 Sandbag   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-July 08

Re: 'cout' Undeclared (first Use This Function)

Posted 08 July 2008 - 01:38 AM

Sorry for bump, but i'm getting the exact same problem as the creator of this thread.

here's a screen shot right after compile:
http://img92.imagesh...startingtu3.jpg

please help! thanks :)
Was This Post Helpful? 0
  • +
  • -

#27 red_4900   User is offline

  • Code T(h)inkers
  • member icon

Reputation: 21
  • View blog
  • Posts: 1,120
  • Joined: 22-February 08

Re: 'cout' Undeclared (first Use This Function)

Posted 08 July 2008 - 03:19 AM

change it to:
#include<iostream>
using namespace std;
int main(void){
	cout<<"hello~"<<endl;
	return 0;
	} 

Was This Post Helpful? 0
  • +
  • -

#28 gabehabe   User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1433
  • View blog
  • Posts: 11,006
  • Joined: 06-February 08

Re: 'cout' Undeclared (first Use This Function)

Posted 08 July 2008 - 03:28 AM

The problem is that you have a capital 'C' for cout, it should all be lower case :)
Was This Post Helpful? 0
  • +
  • -

#29 sny2ksa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-May 09

Re: 'cout' Undeclared (first Use This Function)

Posted 04 November 2009 - 11:52 AM

View PostDivineFlux, on 6 Jan, 2005 - 10:33 AM, said:

Ok, so I'm really confused here. :huh: I got "C++ for Dummies" for Christmas and was starting to work through the book. Did the first coding exercise (which was basicly just to see how a simple program looked) but that is as far as I've gotten.

I keep getting these errors that say
'cout' undeclared (first use this function)
and
'cin' undeclared (first use this function)
but the coding is written exactly as in the example. I even tried it with the pre-made file and still get the same error.

Here is the code from the pre-made example file:

//
//  Conversion - convert temperature from Celsius
//           degree units into Fahrenheit degree
//               units:
//      Fahrenheit = Celsius  * (212 - 32)/100 + 32
//
#include <stdio.h>
#include <iostream.h>
int main(int nNumberofArgs, char* pszArgs[])
{
    // enter the temperature in Celsius
    int nCelsius;
    cout << "Enter the temperature in Celsius:";
    cin  >> nCelsius;

    // calculate conversion factor for Celsius
    // to Fahrenheit
    int nFactor;
    nFactor = 212 - 32;

    // use conversion factor to convert Celsius
    // into Fahrenheit values
    int nFahrenheit;
    nFahrenheit = nFactor * nCelsius/100 + 32;

    // output the results
    cout << "Fahrenheit value is:";
    cout << nFahrenheit;

    return 0;
}



The two errors that I get are:

Error: error: 'cout' undeclared (first use this function)
Error: error: 'cin' undeclared (first use this function)


I'm using the latest software from DJGPP (which is the updated version of what comes with the book) for Win2K.

I am hoping that I'll have less problems with all of this once I get Visual Studio.NET running on my 'puter.

Thanks for all your help.



i am using dev c++ n i got the same errors .the solution th8 i found is first remove .h from iostream and then add this line beneath the #include line
using namespace std; may be u too got solution..
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2