Click here to Skip to main content
15,353,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is Dog.h
#pragma once
#include <list>

class SerializedObject;

class Dog
	static const int SID = 1;
	static Dog* NewDog() { return nullptr; }
	static void DeleteAll() {}
	static Dog* CreateFromSO(SerializedObject* tSO) { return nullptr; }
	static Dog* FindDogFromID(int tID) { return nullptr; }

	int mAge = 0;

	SerializedObject* Serialize() { return nullptr; }// Only we know how to smoosh ourselves.  Everyone knows what an SO is

	int mObjectID = 0; // Which Dog object am I?
	Dog() {} // Can't make a person without going through our factory

	static std::list<Dog*> sAllDogs;


What I have tried:

now I need to create some new dogs in the main()
I have tried to do it like this: Dog* Dog1 = new Dog;
but I have errored with Dog and have no idea why it happened. Could you guys help me pls?
Updated 29-Mar-22 21:50pm

I believe your problem can be summarized by this line in your code :
Dog() {} // Can't make a person without going through our factory
Sometimes a static method of the class is used by the factory to create new objects but I don't see any methods here that do anything constructive - they all return nullptr.

PS - pun intended. ;)
CPallini 30-Mar-22 2:16am
For some reason you are using a private constructor.Of course, you can't call this up directly.
Here is the principle how it could look like :
c++ - How to create an object of a class, who has a private constructor - Stack Overflow[^]
Rick is right and so need to reshuffle some code. I missing a useable Dog-factory like

Dog* createName(String *master, String *kind, String birthday, int gender, String *dogName);
CPallini 30-Mar-22 4:02am
Why should a Dog-factory create 'names' ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900