-1

I tried to make a header called Paitent_info.h as you can see here :

#ifdef GUARD_Paitent_info
#define GUARD_Paitent_info

#include <iostream>
#include <string>
#include <vector>

struct Paitent_info {
    std::string name;
    std::vector<double> tem;
};

bool compare(const Paitent_info&, const Paitent_info&);
std::istream& read(std::istream&, Paitent_info&);
std::istream& read_tem(std::istream&, std::vector<double>&);
#endif

and here is Paitent_info.cpp :

#include "Paitent_info.h"

using std::istream; using std::vector;

bool compare(const Paitent_info& x, const Paitent_info& y)
{
    return x.name < y.name;
}


istream& read(istream& ip, Paitent_info& p)
{ // do something
    return ip;
}

istream& read_tem(istream& in, vector<double>& tem)
{ // do something
    return in;
}

I got many error messages from this code :

  1. std::istream and std::vector has not been declared
  2. Paitent_info does not name a type.
  3. request for member ‘name’ in ‘x’ and 'y', which is of non-class type ‘const int’.
  4. istream does not name a type.

I do not know why I got all these error messages, please help me.

johnsyweb
  • 136,902
  • 23
  • 188
  • 247
test me
  • 83
  • 1
  • 7

1 Answers1

6

You got a typo in the header guard:

#ifdef GUARD_Paitent_info

should be

#ifndef GUARD_Paitent_info

Currently the guard causes the header to be included only if it already has been included. Think about that for a second ;).

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185