Dev C++ Cout Does Not Name A Type

Dev C++ Cout Does Not Name A Type

I was learning Adam Drozdek's book 'Data Structures and Algorithms in C', well, I typed the code in page 15 in my vim and compiled it in terminal of my Ubuntu 11.10.

Alchemy vst windows download windows 7

C++ Error Type Cout

  1. This is interpreted as a function prototype, that is you have declared a function that takes no parameters and returns type Alien. This links because the function is not actually called so it does not have to exist. To instantiate an alien using the default constructor you should change this to.
  2. Offt is a POSIX type, but not an ISO-C (ANSI) type. If you compile with -ansi, (or any of the other standards selection options which asserts STRICTANSI checking), you cannot expect it to be defined by the compiler implementation; it is a non-standard option with user-namespace semantics, so you need to define it. Off64t is similar, but currently not even a POSIX standard type, AFAIK.
  3. The Mozilla team are not newbies nor Microsoft devs, and they are activelly working on Rust, I guess for them C is not utterly irreplaceable. That every line of C/C will be Rust or that C/C are soon to be dead is nonsense, not even COBOL is dead yet.

Cout’ Does Not Name A Type

P: 1
when I compile it :
hxjnsq@hxjnsq-VirtualBox:~$ g++ stat.cc
stat.cc:19:11: error: ‘ostream’ does not name a type
stat.cc:49:1: error: ‘ostream’ does not name a type
stat.cc: In function ‘int main(int, char**)’:
stat.cc:100:1: error: ‘cerr’ was not declared in this scope
stat.cc:104:1: error: ‘cout’ was not declared in this scope
I don't know why?
  1. //stat.cc
  2. #include<iostream>
  3. #include<string.h>
  4. #include<errno.h>
  5. #include<sys/types.h>
  6. #include<sys/stat.h>
  7. #include<ostream>
  8. class Stat : public stat
  9. {
  10. private:
  11. char *path;
  12. int fd;
  13. public:
  14. Stat(){path=0;fd=-1;}
  15. ~Stat();
  16. Stat & examine(const char *pathname);
  17. Stat & examine(int fd);
  18. int operator(Stat &o);
  19. friend ostream & operator<<(ostream &out , Stat &o);
  20. };
  21. Stat::~Stat()
  22. {
  23. if(path)
  24. delete path;
  25. }
  26. Stat & Stat::examine(const char *pathname)
  27. {
  28. if(path)
  29. delete path;
  30. path=strdup(pathname);
  31. fd=-1;
  32. if(::stat(path,this)-1)
  33. throw errno;
  34. return *this;
  35. }
  36. Stat & Stat::examine(int fd)
  37. {
  38. if(path)
  39. {
  40. delete path;
  41. path=0;
  42. }
  43. this->fd=fd;
  44. if(::fstat(fd,this)-1)
  45. throw errno;
  46. return *this;
  47. }
  48. ostream & operator<<(ostream &out , Stat &o)
  49. {
  50. if(o.fd-1&&!o.path)
  51. {
  52. out<<'No current infomation.'
  53. return out;
  54. }
  55. if(o.path)
  56. cout<<'stat('<<o.path<<'){n';
  57. else
  58. cout<<'fstat('<<o.fd<<'){n';
  59. cout<<'tst_dev=t'<<o.st_dev<<';n'
  60. <<'tst_ino=t'<<o.st_ino<<';n';
  61. cout.setf(ios::oct,ios::basefield);
  62. cout<<'tst_mode=t'<<'0'<<o.st_mode<<';n';
  63. cout.setf(ios::dec,ios::basefield);
  64. cout<<'tst_nlink=t'<<o.st_nlink<<';n'
  65. <<'tst_uid=t'<<o.st_uid<<';n'
  66. <<'tst_gid=t'<<o.st_gid<<';n'
  67. <<'tst_rdev=t'<<o.st_rdev<<';n'
  68. <<'tst_atime=t'<<o.st_atime<<';n';
  69. return out;
  70. }
  71. int Stat::operator(Stat &o)
  72. {
  73. if(fd-1&&!path)
  74. throw EINVAL;
  75. if(o.fd-1 && !o.path)
  76. throw EINVAL;
  77. if(o.st_dev!=st_dev o.st_ino!=st_ino)
  78. return 0;
  79. return 1;
  80. }
  81. int main(int argc,char **argv)
  82. {
  83. int x;
  84. Stat t;
  85. Stat s;
  86. t.examine('./stat');
  87. for(x=1;x<argc;++x)
  88. {
  89. try{
  90. s.examine(argv[x]);
  91. }catch(int e)
  92. {
  93. cerr<<strerror(e)<<':stat(2) of'
  94. <<argv[x]<<'n';
  95. continue;
  96. }
  97. cout<<s<<'n';
  98. cout<<''<<argv[x]<<' is'
  99. <<(st?'same':'not the same')
  100. <<'file as ./statn';
  101. }
  102. return 0;
  103. }

Dev C Cout Does Not Name A Type B

P: 3
Hey, all passby c++ programmer, I met a problem which has baffled me for a while:
It is my first time to use Kdevelop and I am also not very conversant with C++. I created two classes: Dead and Born.
They are declared in 'dead.h' and 'born.h' respectively.
The content of born.h is like the following:
  1. ////////////////////////////////////////////////////
  2. #ifndef BORN_H
  3. #define BORN_H
  4. #include 'dead.h'
  5. using namespace std;
  6. /**
  7. @author shark, <shark@KOF>
  8. */
  9. class born
  10. {
  11. public:
  12. born();
  13. ~born();
  14. public:
  15. dead test1;
  16. };
  17. #endif
  18. ////////////////////////////////////////////
OK, then comes the content of 'dead.h'
  1. ///////////////////////////////////////////
  2. #ifndef DEAD_H
  3. #define DEAD_H
  4. #include 'born.h'
  5. using namespace std;
  6. /**
  7. @author shark, <shark@KOF>
  8. */
  9. class dead
  10. {
  11. public:
  12. dead_ele();
  13. ~dead_ele();
  14. public:
  15. born test2;
  16. };
  17. #endif
  18. ////////////////////////////////////////////
These two classes were added by Kdevelop 'New Class' item,
When I compiled the code, g++ complained:
/home/shark/TCL_project/peptide_world/src/born.h:44: error: 'dead' does not name a type
/home/shark/TCL_project/peptide_world/src/dead.h:42: error: 'born' does not name a type
But I indeed include all the necessary head file. How could that be? I tried to add the prefix of namespace reference, but it still complains..
Any ideas?
Comments are closed.