“TypePtr does not name a type after” including ‘typedefs.h’

I’m writing a project for univeristy. I wrote a function Vehicle.getActualCost(), tested it in VehicleTest.cpp and everything is working smoothly.

Problem occurs when in these tests I change Vehicle* to VehiclePtr as per professor’s instruction.
VehiclePtr is a type declared in typedefs.h file, which looks like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#ifndef CARRENTAL_TYPEDEFS_H
#define CARRENTAL_TYPEDEFS_H
#include "model/Client.h"
#include "model/Address.h"
#include "model/Rent.h"
#include "model/Vehicle.h"
typedef Address* AddressPtr;
class Rent;
typedef Rent* RentPtr;
class Client;
typedef Client* ClientPtr;
typedef Vehicle* VehiclePtr;
#endif //CARRENTAL_TYPEDEFS_H
</code>
<code>#ifndef CARRENTAL_TYPEDEFS_H #define CARRENTAL_TYPEDEFS_H #include "model/Client.h" #include "model/Address.h" #include "model/Rent.h" #include "model/Vehicle.h" typedef Address* AddressPtr; class Rent; typedef Rent* RentPtr; class Client; typedef Client* ClientPtr; typedef Vehicle* VehiclePtr; #endif //CARRENTAL_TYPEDEFS_H </code>
#ifndef CARRENTAL_TYPEDEFS_H
#define CARRENTAL_TYPEDEFS_H

#include "model/Client.h"
#include "model/Address.h"
#include "model/Rent.h"
#include "model/Vehicle.h"

typedef Address* AddressPtr;

class Rent;
typedef Rent* RentPtr;

class Client;
typedef Client* ClientPtr;

typedef Vehicle* VehiclePtr;

#endif //CARRENTAL_TYPEDEFS_H

After which I get errors like these:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>In file included from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Client.h:8,
from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/typedefs.h:8,
from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/test/VehicleTest.cpp:6:
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:24:5: error: ‘ClientPtr’ does not name a type
24 | ClientPtr client;
| ^~~~~~~~~
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:26:5: error: ‘VehiclePtr’ does not name a type; did you mean ‘Vehicle’?
26 | VehiclePtr vehicle;
| ^~~~~~~~~~
| Vehicle
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:33: error: ‘ClientPtr’ has not been declared
40 | Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);
| ^~~~~~~~~
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:51: error: ‘VehiclePtr’ has not been declared
40 | Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);
| ^~~~~~~~~~
...
</code>
<code>In file included from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Client.h:8, from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/typedefs.h:8, from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/test/VehicleTest.cpp:6: /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:24:5: error: ‘ClientPtr’ does not name a type 24 | ClientPtr client; | ^~~~~~~~~ /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:26:5: error: ‘VehiclePtr’ does not name a type; did you mean ‘Vehicle’? 26 | VehiclePtr vehicle; | ^~~~~~~~~~ | Vehicle /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:33: error: ‘ClientPtr’ has not been declared 40 | Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime); | ^~~~~~~~~ /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:51: error: ‘VehiclePtr’ has not been declared 40 | Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime); | ^~~~~~~~~~ ... </code>
In file included from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Client.h:8,
                 from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/typedefs.h:8,
                 from /mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/test/VehicleTest.cpp:6:
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:24:5: error: ‘ClientPtr’ does not name a type
   24 |     ClientPtr client;
      |     ^~~~~~~~~
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:26:5: error: ‘VehiclePtr’ does not name a type; did you mean ‘Vehicle’?
   26 |     VehiclePtr vehicle;
      |     ^~~~~~~~~~
      |     Vehicle
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:33: error: ‘ClientPtr’ has not been declared
   40 |     Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);
      |                                 ^~~~~~~~~
/mnt/c/Users/szindzeks/CLionProjects/atom_cz_1215_03/majkowski/workshop/library/include/model/Rent.h:40:51: error: ‘VehiclePtr’ has not been declared
   40 |     Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);
      |                                                   ^~~~~~~~~~

...

Client.h

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#ifndef CARRENTAL_CLIENT_H
#define CARRENTAL_CLIENT_H
#include "Rent.h"
#include "typedefs.h"
#include <vector>
class Client {
private:
std::string firstName;
std::string lastName;
const std::string personalID;
AddressPtr address;
std::vector<Rent*> currentRents;
public:
Client(const std::string &firstName, const std::string &lastName, const std::string &personalID, AddressPtr address);
~Client();
std::string getInfo() const;
std::string getFullInfo() const;
const std::string &getFirstName() const;
const std::string &getLastName() const;
const std::string &getPersonalID() const;
const AddressPtr getAddress() const;
const std::vector<RentPtr> & getCurrentRents() const;
void setFirstName(const std::string &firstName);
void setLastName(const std::string &lastName);
void setAddress(AddressPtr address);
void addNewRent(RentPtr newRent);
void removeRent(unsigned int rentID);
void removeRent(RentPtr rentToRemove);
};
#endif //CARRENTAL_CLIENT_H
</code>
<code>#ifndef CARRENTAL_CLIENT_H #define CARRENTAL_CLIENT_H #include "Rent.h" #include "typedefs.h" #include <vector> class Client { private: std::string firstName; std::string lastName; const std::string personalID; AddressPtr address; std::vector<Rent*> currentRents; public: Client(const std::string &firstName, const std::string &lastName, const std::string &personalID, AddressPtr address); ~Client(); std::string getInfo() const; std::string getFullInfo() const; const std::string &getFirstName() const; const std::string &getLastName() const; const std::string &getPersonalID() const; const AddressPtr getAddress() const; const std::vector<RentPtr> & getCurrentRents() const; void setFirstName(const std::string &firstName); void setLastName(const std::string &lastName); void setAddress(AddressPtr address); void addNewRent(RentPtr newRent); void removeRent(unsigned int rentID); void removeRent(RentPtr rentToRemove); }; #endif //CARRENTAL_CLIENT_H </code>
#ifndef CARRENTAL_CLIENT_H
#define CARRENTAL_CLIENT_H

#include "Rent.h"
#include "typedefs.h"
#include <vector>

class Client {

private:
    std::string firstName;
    std::string lastName;
    const std::string personalID;
    AddressPtr address;
    std::vector<Rent*> currentRents;

public:
    Client(const std::string &firstName, const std::string &lastName, const std::string &personalID, AddressPtr address);
    ~Client();

    std::string getInfo() const;
    std::string getFullInfo() const;
    const std::string &getFirstName() const;
    const std::string &getLastName() const;
    const std::string &getPersonalID() const;
    const AddressPtr getAddress() const;
    const std::vector<RentPtr> & getCurrentRents() const;

    void setFirstName(const std::string &firstName);
    void setLastName(const std::string &lastName);
    void setAddress(AddressPtr address);

    void addNewRent(RentPtr newRent);
    void removeRent(unsigned int rentID);
    void removeRent(RentPtr rentToRemove);

};

#endif //CARRENTAL_CLIENT_H

Rent.h

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#ifndef CARRENTAL_RENT_H
#define CARRENTAL_RENT_H
#include "Vehicle.h"
#include "Client.h"
#include "typedefs.h"
#include <boost/date_time.hpp>
#include <math.h>
namespace pt = boost::posix_time;
namespace gr = boost::gregorian;
class Rent {
private:
const unsigned int id;
ClientPtr client;
VehiclePtr vehicle;
unsigned int rentCost = 0;
pt::ptime beginTime;
pt::ptime endTime = pt::not_a_date_time;
public:
Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);
const unsigned int getId() const;
const ClientPtr getClient() const;
const VehiclePtr getVehicle() const;
const pt::ptime &getBeginTime() const;
const pt::ptime &getEndTime() const;
std::string getInfo() const;
unsigned int getRentDays() const;
unsigned int getRentCost() const;
void endRent(pt::ptime endTime);
};
#endif //CARRENTAL_RENT_H
</code>
<code>#ifndef CARRENTAL_RENT_H #define CARRENTAL_RENT_H #include "Vehicle.h" #include "Client.h" #include "typedefs.h" #include <boost/date_time.hpp> #include <math.h> namespace pt = boost::posix_time; namespace gr = boost::gregorian; class Rent { private: const unsigned int id; ClientPtr client; VehiclePtr vehicle; unsigned int rentCost = 0; pt::ptime beginTime; pt::ptime endTime = pt::not_a_date_time; public: Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime); const unsigned int getId() const; const ClientPtr getClient() const; const VehiclePtr getVehicle() const; const pt::ptime &getBeginTime() const; const pt::ptime &getEndTime() const; std::string getInfo() const; unsigned int getRentDays() const; unsigned int getRentCost() const; void endRent(pt::ptime endTime); }; #endif //CARRENTAL_RENT_H </code>
#ifndef CARRENTAL_RENT_H
#define CARRENTAL_RENT_H

#include "Vehicle.h"
#include "Client.h"
#include "typedefs.h"
#include <boost/date_time.hpp>
#include <math.h>

namespace pt = boost::posix_time;
namespace gr = boost::gregorian;

class Rent {
private:
    const unsigned int id;
    ClientPtr client;
    VehiclePtr vehicle;
    unsigned int rentCost = 0;
    pt::ptime beginTime;
    pt::ptime endTime = pt::not_a_date_time;

public:
    Rent(const unsigned int id, ClientPtr client, VehiclePtr vehicle, pt::ptime beginTime);

    const unsigned int getId() const;
    const ClientPtr getClient() const;
    const VehiclePtr getVehicle() const;
    const pt::ptime &getBeginTime() const;
    const pt::ptime &getEndTime() const;

    std::string getInfo() const;
    unsigned int getRentDays() const;
    unsigned int getRentCost() const;
    void endRent(pt::ptime endTime);

};

#endif //CARRENTAL_RENT_H

And the VehicleTest.cpp

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#include <boost/test/unit_test.hpp>
#include "model/Bicycle.h"
#include "model/MotorVehicle.h"
#include "model/Car.h"
#include "model/Moped.h"
#include "typedefs.h"
BOOST_AUTO_TEST_SUITE(TestSuiteVehicle)
...
BOOST_AUTO_TEST_CASE(VehicleActualPriceTests){
VehiclePtr vehicle = new Vehicle("E", 1000);
...
VehiclePtr car5 = new Car("E", 1000, 2500, E);
BOOST_TEST(vehicle->getActualRentalPrice() == vehicle->getBasePrice());
BOOST_TEST(bicycle->getActualRentalPrice() == bicycle->getBasePrice());
...
BOOST_TEST(car5->getActualRentalPrice() == (int)(car5->getBasePrice() * 1.5 * 1.5));
delete vehicle;
...
delete car5;
}
</code>
<code>#include <boost/test/unit_test.hpp> #include "model/Bicycle.h" #include "model/MotorVehicle.h" #include "model/Car.h" #include "model/Moped.h" #include "typedefs.h" BOOST_AUTO_TEST_SUITE(TestSuiteVehicle) ... BOOST_AUTO_TEST_CASE(VehicleActualPriceTests){ VehiclePtr vehicle = new Vehicle("E", 1000); ... VehiclePtr car5 = new Car("E", 1000, 2500, E); BOOST_TEST(vehicle->getActualRentalPrice() == vehicle->getBasePrice()); BOOST_TEST(bicycle->getActualRentalPrice() == bicycle->getBasePrice()); ... BOOST_TEST(car5->getActualRentalPrice() == (int)(car5->getBasePrice() * 1.5 * 1.5)); delete vehicle; ... delete car5; } </code>
#include <boost/test/unit_test.hpp>
#include "model/Bicycle.h"
#include "model/MotorVehicle.h"
#include "model/Car.h"
#include "model/Moped.h"
#include "typedefs.h"

BOOST_AUTO_TEST_SUITE(TestSuiteVehicle)

    ...

    BOOST_AUTO_TEST_CASE(VehicleActualPriceTests){
        VehiclePtr vehicle = new Vehicle("E", 1000);
        ...
        VehiclePtr car5 = new Car("E", 1000, 2500, E);

        BOOST_TEST(vehicle->getActualRentalPrice() == vehicle->getBasePrice());
        BOOST_TEST(bicycle->getActualRentalPrice() == bicycle->getBasePrice());
        ...
        BOOST_TEST(car5->getActualRentalPrice() == (int)(car5->getBasePrice() * 1.5 *  1.5));

        delete vehicle;
        ...
        delete car5;
    }

I of course expected for it to work no problem after #inlucde "typedefs.h", but it didn’t.

I tried different #include variations, changing the typedefs.h file but the effect was even worse or the same.

The program compiles and work as expected. The tests however, do not compile.

I’d be really thankful if someone was able to help me.

New contributor

Kacper Majkowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật