Click here to Skip to main content
15,885,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: what is contained in iostream and std Pin
CPallini29-Nov-17 1:23
mveCPallini29-Nov-17 1:23 
AnswerRe: what is contained in iostream and std Pin
jschell29-Nov-17 12:39
jschell29-Nov-17 12:39 
QuestionC++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_27-Nov-17 14:23
Vaclav_27-Nov-17 14:23 
QuestionRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
David Crow27-Nov-17 16:47
David Crow27-Nov-17 16:47 
AnswerRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
CPallini27-Nov-17 21:31
mveCPallini27-Nov-17 21:31 
AnswerRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Jochen Arndt27-Nov-17 21:26
professionalJochen Arndt27-Nov-17 21:26 
AnswerRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Richard MacCutchan27-Nov-17 21:53
mveRichard MacCutchan27-Nov-17 21:53 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_28-Nov-17 4:09
Vaclav_28-Nov-17 4:09 
OK, here is readers digest for clarification.
The class TESTCLASS1 header is included in HF_VNA_CROSS_CPP.cpp.
This file first code line is
#define MY_DEBUG
and the cout code works in main OK
BUT not in TESTCLASS1.h UNTIL I add / redefine MY_DEBUG.

Without the
#include <iostream>
using namespace std;

added to TESTCLASS1.h

When I add ONLY #define MY_DEBUG
I get the cout error.
Basically I have two issues
1. why do I need to redefine MY_DEBUG in TESTCLASS1.h
2. why do I need to add #include <iostream>
using namespace std; to get cout to work in added class

and a minor request for help with
should I #include "TESTCLASS1.cpp" in main file instead of "header" #include "TESTCLASS1.h" file?





<pre lang="c++">//============================================================================
// Name : HF_VNA_CROSS_CPP.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#define MY_DEBUG

#include <iostream>
using namespace std;

#include <math.h> // rint round up math
#include <stdio.h>
#include <stdlib.h>

#include <fcntl.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <math.h> // rint round up math
#include "/usr/local/include/wiringPiSPI.h"

#include <math.h> // rint round up math libraray lm


#include "flash_DTR.h" // flash DTR via USB port
/* CCC temp out
#include "AD9851.h" // AD9851 via SPI / I2C
#include "LCD_SPI.h" // LCD via SPI
*/

#include "MY_wiringPi.h" // GPIO for RPi

//#include "LCD.h" // TEST CLASS
//#include "TESTCLASS.h" //
//#include "LCDSPI.h" // NO SPACE

#include "TESTCLASS1.h"

int main() {
cout << "NEW *** COPY 2 TEST output HF_VNA_CROSS_CPP CPP Managed project" << endl; // prints CPP Managed project

//temp bypass CCC
// class test block start
{
#ifdef MY_DEBUG
cout << " process code block START"<< endl;
cout << "*** TRACE file " << __FILE__<< endl;
cout <<" function " <<__FUNCTION__<<endl;
cout << " line " << __LINE__<< endl;
#endif
//LCD__SPI lcd; // double space INSTATIATE CLASS
//lcd.TestFunction();
TEST_CLASS_1 test_class;
test_class.TestFunction();

}
// class test block end
// */
return 43;

#ifdef MY_DEBUG
cout << "*** TRACE file " << __FILE__<<" line " <<__LINE__<< " function "<< __FUNCTION__ << endl;
//return 42;
#endif


flash();
// process code block START
{
#ifdef MY_DEBUG
cout << " process code block START"<< endl;
cout << "*** TRACE file " << __FILE__<< endl;
cout <<" function " <<__FUNCTION__<<endl;
cout << " line " << __LINE__<< endl;
#endif
// process code block END
#ifdef MY_DEBUG
cout << " process code block END"<< endl;
cout << "*** TRACE file " << __FILE__<< endl;
cout <<" function " <<__FUNCTION__<<endl;
cout << " line " << __LINE__<< endl;
#endif
}

/* temp bypass CCC
// class test block start
{
LCD lcd; // INSTATIATE CLASS

//lcd.TestFunction(10);
}
// class test block end
*/
}

/*
* TESTCLASS1.h
*
* Created on: Nov 28, 2017
* Author: os64
*/

#ifndef TESTCLASS1_H_
#define TESTCLASS1_H_

#define MY_DEBUG

namespace std {

class TEST_CLASS_1 {
public:
TEST_CLASS_1();
virtual ~TEST_CLASS_1();

int TestFunction(void);
};

} /* namespace std */

#endif /* TESTCLASS1_H_ */

08:42:36 **** Incremental Build of configuration Debug for project HF_VNA_CROSS_CPP2 ****
make all
Building file: ../src/TESTCLASS1.cpp
Invoking: Cross G++ Compiler
arm-linux-gnueabihf-g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TESTCLASS1.d" -MT"src/TESTCLASS1.o" -o "src/TESTCLASS1.o" "../src/TESTCLASS1.cpp"
../src/TESTCLASS1.cpp: In member function ‘int std::TEST_CLASS_1::TestFunction()’:
../src/TESTCLASS1.cpp:26:4: error: ‘cout’ was not declared in this scope
cout << " process code block START"<< endl;
^
../src/TESTCLASS1.cpp:26:43: error: ‘endl’ was not declared in this scope
cout << " process code block START"<< endl;
^
make: *** [src/TESTCLASS1.o] Error 1
src/subdir.mk:39: recipe for target 'src/TESTCLASS1.o' failed

08:42:36 Build Finished (took 304ms)


</pre>
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Richard MacCutchan28-Nov-17 4:25
mveRichard MacCutchan28-Nov-17 4:25 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_28-Nov-17 7:07
Vaclav_28-Nov-17 7:07 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Richard MacCutchan28-Nov-17 8:37
mveRichard MacCutchan28-Nov-17 8:37 
AnswerRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Jochen Arndt28-Nov-17 4:54
professionalJochen Arndt28-Nov-17 4:54 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_28-Nov-17 7:46
Vaclav_28-Nov-17 7:46 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Jochen Arndt28-Nov-17 8:39
professionalJochen Arndt28-Nov-17 8:39 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
David Crow28-Nov-17 8:14
David Crow28-Nov-17 8:14 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_28-Nov-17 11:26
Vaclav_28-Nov-17 11:26 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
David Crow28-Nov-17 14:03
David Crow28-Nov-17 14:03 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Richard MacCutchan28-Nov-17 21:40
mveRichard MacCutchan28-Nov-17 21:40 
AnswerRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_28-Nov-17 12:25
Vaclav_28-Nov-17 12:25 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Jochen Arndt28-Nov-17 21:28
professionalJochen Arndt28-Nov-17 21:28 
GeneralRe: C++ cout in header file error - ‘cout’ was not declared in this scope Pin
Vaclav_29-Nov-17 17:36
Vaclav_29-Nov-17 17:36 
Questionem_setwordbreakproc in MFC Pin
ForNow26-Nov-17 14:05
ForNow26-Nov-17 14:05 
AnswerRe: em_setwordbreakproc in MFC Pin
Richard MacCutchan26-Nov-17 21:37
mveRichard MacCutchan26-Nov-17 21:37 
GeneralRe: em_setwordbreakproc in MFC Pin
ForNow27-Nov-17 1:52
ForNow27-Nov-17 1:52 
GeneralRe: em_setwordbreakproc in MFC Pin
Richard MacCutchan27-Nov-17 6:23
mveRichard MacCutchan27-Nov-17 6:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.