Expected ‘)’ before ‘*’ in constructor even though there’s no reason a ‘)’ should be there in c++

I’m writing a small game engine project and I’m having trouble with this constructor. For some weird reason g++ says I need to add a ‘)’ in a spot where there’s no reason to add one. Neither I nor Visual Studio Code see anything wrong with it and I’ve been looking at this for 20 minutes trying to see if something is wrong. The error is occurring in the PhysicsObject and Renderable constructors.

GameObject does not need to be fully qualified. I have written GameObject on its own everywhere else in the program and it is not a part of its own namespace or anything. In fact I have made constructors that look almost identical to this one with no error.

(including the full code just in case there’s a stupid typo or something)

PhysicsObject.h

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#pragma once
#include <string>
#include "Node.h"
#include "Transform.h"
#include "GameObject.h"
class PhysicsObject : public Node {
protected:
Transform * transform;
void move(double dt);
void accelerate(double dt);
public:
PhysicsObject(GameObject * obj, std::string name) : Node(name) {
transform = obj->transform;
obj->nodes[name] = this;
}
void update(double dt);
void destroy() { delete this; }
Vector2 velocity = Vector2D::zero;
Vector2 acceleration = Vector2D::zero;
};
</code>
<code>#pragma once #include <string> #include "Node.h" #include "Transform.h" #include "GameObject.h" class PhysicsObject : public Node { protected: Transform * transform; void move(double dt); void accelerate(double dt); public: PhysicsObject(GameObject * obj, std::string name) : Node(name) { transform = obj->transform; obj->nodes[name] = this; } void update(double dt); void destroy() { delete this; } Vector2 velocity = Vector2D::zero; Vector2 acceleration = Vector2D::zero; }; </code>
#pragma once

#include <string>

#include "Node.h"
#include "Transform.h"
#include "GameObject.h"

class PhysicsObject : public Node {
    protected:
    Transform * transform;

    void move(double dt);
    void accelerate(double dt);

    public:

    PhysicsObject(GameObject * obj, std::string name) : Node(name) {
        transform = obj->transform;
        obj->nodes[name] = this;
    }

    void update(double dt);

    void destroy() { delete this; }

    Vector2 velocity = Vector2D::zero;
    Vector2 acceleration = Vector2D::zero;
};

Renderable.h

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#pragma once
#include <vector>
#include <string>
#include "Node.h"
#include "SDL2/SDL.h"
#include "Vector2.h"
#include "GameObject.h"
#include "Transform.h"
class Renderable : public Node {
public:
static inline std::vector<Renderable *> allRenderables;
protected:
//0-255
int r = 255;
int g = 255;
int b = 255;
int a = 255;
Transform * transform;
Renderable(GameObject * obj, std::string name) : Node(name) {
transform = obj->transform;
allRenderables.push_back(this);
}
public:
virtual void update(double dt);
virtual void render() {};
void destroy() {
delete this;
}
};
</code>
<code>#pragma once #include <vector> #include <string> #include "Node.h" #include "SDL2/SDL.h" #include "Vector2.h" #include "GameObject.h" #include "Transform.h" class Renderable : public Node { public: static inline std::vector<Renderable *> allRenderables; protected: //0-255 int r = 255; int g = 255; int b = 255; int a = 255; Transform * transform; Renderable(GameObject * obj, std::string name) : Node(name) { transform = obj->transform; allRenderables.push_back(this); } public: virtual void update(double dt); virtual void render() {}; void destroy() { delete this; } }; </code>
#pragma once

#include <vector>
#include <string>

#include "Node.h"
#include "SDL2/SDL.h"
#include "Vector2.h"
#include "GameObject.h"
#include "Transform.h"

class Renderable : public Node {
    public:
    static inline std::vector<Renderable *> allRenderables;
    
    protected:

    //0-255
    int r = 255;
    int g = 255;
    int b = 255;
    int a = 255;

    Transform * transform;

    Renderable(GameObject * obj, std::string name) : Node(name) {
        transform = obj->transform;
        allRenderables.push_back(this);
    }

    public:
    virtual void update(double dt);
    
    virtual void render() {};

    void destroy() {
        delete this;
    }
    
};

Here’s the error message:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>In file included from include/GameObject.h:3,
from GameObject.cpp:3:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
26 | Renderable(GameObject * obj, std::string name) : Node(name) {
| ~ ^~
| )
In file included from include/GameObject.h:3,
from include/PhysicsObject.h:7,
from PhysicsObject.cpp:1:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
26 | Renderable(GameObject * obj, std::string name) : Node(name) {
| ~ ^~
| )
In file included from include/GameObject.h:3,
from test.cpp:6:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
26 | Renderable(GameObject * obj, std::string name) : Node(name) {
| ~ ^~
| )
In file included from test.cpp:9:
include/Rectangle.h: In constructor ‘Rectangle::Rectangle(float, float, bool, GameObject*, std::string)’:
include/Rectangle.h:19:27: error: no matching function for call to ‘Renderable::Renderable(GameObject*&, std::string&)
19 | : Renderable(obj, name) {
| ^
In file included from include/GameObject.h:3,
from test.cpp:6:
include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(const Renderable&)
12 | class Renderable : public Node {
| ^~~~~~~~~~
include/Renderable.h:12:7: note: candidate expects 1 argument, 2 provided
include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(Renderable&&)
include/Renderable.h:12:7: note: candidate expects 1 argument, 2 provided
</code>
<code>In file included from include/GameObject.h:3, from GameObject.cpp:3: include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token 26 | Renderable(GameObject * obj, std::string name) : Node(name) { | ~ ^~ | ) In file included from include/GameObject.h:3, from include/PhysicsObject.h:7, from PhysicsObject.cpp:1: include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token 26 | Renderable(GameObject * obj, std::string name) : Node(name) { | ~ ^~ | ) In file included from include/GameObject.h:3, from test.cpp:6: include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token 26 | Renderable(GameObject * obj, std::string name) : Node(name) { | ~ ^~ | ) In file included from test.cpp:9: include/Rectangle.h: In constructor ‘Rectangle::Rectangle(float, float, bool, GameObject*, std::string)’: include/Rectangle.h:19:27: error: no matching function for call to ‘Renderable::Renderable(GameObject*&, std::string&)’ 19 | : Renderable(obj, name) { | ^ In file included from include/GameObject.h:3, from test.cpp:6: include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(const Renderable&)’ 12 | class Renderable : public Node { | ^~~~~~~~~~ include/Renderable.h:12:7: note: candidate expects 1 argument, 2 provided include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(Renderable&&)’ include/Renderable.h:12:7: note: candidate expects 1 argument, 2 provided </code>
In file included from include/GameObject.h:3,
                 from GameObject.cpp:3:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
   26 |     Renderable(GameObject * obj, std::string name) : Node(name) {
      |               ~          ^~
      |                          )
In file included from include/GameObject.h:3,
                 from include/PhysicsObject.h:7,
                 from PhysicsObject.cpp:1:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
   26 |     Renderable(GameObject * obj, std::string name) : Node(name) {
      |               ~          ^~
      |                          )
In file included from include/GameObject.h:3,
                 from test.cpp:6:
include/Renderable.h:26:26: error: expected ‘)’ before ‘*’ token
   26 |     Renderable(GameObject * obj, std::string name) : Node(name) {
      |               ~          ^~
      |                          )
In file included from test.cpp:9:
include/Rectangle.h: In constructor ‘Rectangle::Rectangle(float, float, bool, GameObject*, std::string)’:
include/Rectangle.h:19:27: error: no matching function for call to ‘Renderable::Renderable(GameObject*&, std::string&)’
   19 |     : Renderable(obj, name) {
      |                           ^
In file included from include/GameObject.h:3,
                 from test.cpp:6:
include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(const Renderable&)’
   12 | class Renderable : public Node {
      |       ^~~~~~~~~~
include/Renderable.h:12:7: note:   candidate expects 1 argument, 2 provided
include/Renderable.h:12:7: note: candidate: ‘Renderable::Renderable(Renderable&&)’
include/Renderable.h:12:7: note:   candidate expects 1 argument, 2 provided

I didn’t really know what to try. Looked at the error and looked at my code looking for some kind of typo but I can’t find anything.

Did some searching for the error online but everyone either had a typo, didn’t fully qualify std::string, or something like that.

Also restarted VSC but to no one’s surprise it didn’t change anything.

I do not see what could possibly be wrong. If you need to see the code for the Rectangle class I can send it but I really don’t know how it would be relevant so I am omitting it unless someone asks. I’d really appreciate any help y’all can offer. Thanks!

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