phorce 131 Posting Whiz in Training Featured Poster

@ken_taiken Any reason to why the for loop goes from (0 - {first input})? E.g. 5 (0-5)?

phorce 131 Posting Whiz in Training Featured Poster

First question:

Where do you define:

for(;i<right && (data[i]<=data[pivot]);i++) { compares++; }

compares?

Second of all, you have function declartion:

vector<int> quickSort(vector<int> &data, int left, int right) {

This assumes that it has a return type, so therefore is expecting a vector of ints to be returned. BUT you send the pointer (memeory location) of the data so whatever values get's passed to this function, it will perform on THAT dataset therefore, this function can have a return type of "void".

You have a lot of variables, in your code which are not defined (If you had compiled this code, you would have seen them). I have no idea what they do, or, what they are for so I just set these to 0 so that the code compiles. FIX THIS!

Ok, I have a compilable version of your code (Please look through it, don't just copy it)! I have questions though, do you understand the logic behind Quick Sorting? If not, you should research this, also, are you implementing multiple sorting algorithms?

#include <iostream>
#include <string>
#include <vector>
using namespace std;
//Quick Sort

void printSorted(vector<int> &values)
{

    for(unsigned i=0; (i < values.size()); i++)
    {
        cout << values[i] << " ";

    }

    cout << endl << endl;
}

int partition(vector<int> &data, int left, int right){
    int pivot=left;
    int i=left+1;
    int j=right;

    int compares = 0;
    int swaps = 0;
    while (i<j){
        for(;i<right && (data[i]<=data[pivot]);i++) { compares++; }
        for(;(data[j]>data[pivot]);j--) { compares++; }
        if(i<j){
            swap(data[i],data[j]);
            swaps++;
        } …
phorce 131 Posting Whiz in Training Featured Poster

@GilderPilot - Sorry, I misread it. I'm too tired for this! ha

phorce 131 Posting Whiz in Training Featured Poster

I think this is your problem:

mail("name@email.com, $email", "New Request for Tutor", $body, $headers);

Should be:

mail("name@email.com", $email, "New Request for Tutor", $body, $headers);

I assume but like @GilderPilot said, you should check the error log and see where the error is.

phorce 131 Posting Whiz in Training Featured Poster

Hey, yes!

I like to do it this way though, it's personal preference but:

<?php

    if(!isset($_POST['name']))
    {
        echo 'You have not submitted your name';
        return 0;
    }else{
        $name = $_POST['name'];
    }


    if(!isset($_POST['email']))
    {
        echo 'You have not submitted your email';
        return 0;
    }else{
        $email = $_POST['email'];
    }

    if(!isset($_POST['message']))
    {
        echo 'You have not submitted your message';
        return 0;
     }else{
        $message = $_POST['message'];
     }

     if($name && $email && $message)
     {
         $body = "$name has requested a tutor, here is a transcript of their message: $message";
         $headers = "From: $email";
         mail("name@email.com, $email", "New Request for Tutor", $body, $headers);
         header("Location: confirmation.html");

     }  


?>

Hope this helps :)

phorce 131 Posting Whiz in Training Featured Poster

@anna.lucas - This is not the forum for such questions.

"Artifical Remote Enrolement System"?

Lol..

phorce 131 Posting Whiz in Training Featured Poster

Hello,

some compilers (especially with C++) only allow this:

#include <iostream>
....

Could try taking the .h. Is there no way you cannot install GCC?

phorce 131 Posting Whiz in Training Featured Poster

I should have really done some work today, instead I stare looking at work that could have been done.

phorce 131 Posting Whiz in Training Featured Poster

@NardCake Please mark this thread as solved and give rep to those who helped you :)!

phorce 131 Posting Whiz in Training Featured Poster

Hey,

You can use Regex, because you didn't submit any example code, I did an example which hopefully you can follow:

<?php

    $string = "faaf2424_";

    if(preg_match('/^[a-z_\-\d]{3,}$/i', $string))
    {
        echo 'Allowed';
    }else{
        echo 'Not allowed :(';
    }
?>

This would display 'Allowed' whereas if the string was this:

$string = "@24@24@";

Then the output would be: 'Not allowed'

Hope this makes sense!

phorce 131 Posting Whiz in Training Featured Poster

And the problem is...?

phorce 131 Posting Whiz in Training Featured Poster

Super Spice

phorce 131 Posting Whiz in Training Featured Poster

@Dani - I prefer this UI if I am honest, hence I stick on this. But I should check it out sometimes, will my account still work on there OR would I have to create another one?

phorce 131 Posting Whiz in Training Featured Poster

My bucket list:

  • Write a Fast Fourier Transform (It's quite difficult!)
  • Finish my Speech Library off
  • Pay off University fee's
  • Get a decent job where I'll be happy and make a difference :)!
  • Country mannor house where and a home in major cities around the world
phorce 131 Posting Whiz in Training Featured Poster

@Dani

I didn't know ProgrammingForums existed! Is it owned by DaniWeb?

phorce 131 Posting Whiz in Training Featured Poster

Hello there.

It appears that some other people are having the same problem with you and the forums. Weird.

I like Arduino but have you tried Raspberry Pi?

Welcome to the forums :)!

phorce 131 Posting Whiz in Training Featured Poster

Have you tried posting this in the Java forum?

phorce 131 Posting Whiz in Training Featured Poster

Hey,

Off-topic: What University and what year are you in?

I'll give you some hope:

When I was in my first and second year at University, I posted code here all the time and no code was copied (I'm not saying that this would happen in your case) BUT what I am saying is that, if EVERYONE has the same assignment, then, it is likely that parts of your code will look the same anyway. Your tutor, or, external examiners are not looking for the fact "Hey he can do conditional statements" more as the fact that you understand the logic behind the assignment (How does inheritence/Association etc..) work.

The likelyhood of someone finding this, as well, after you mark it as "solved" will be very unlikely, or, probablamtic since a lot of questions get's asked daily which ,eans they would most likely ask the same /or/ simular question anyway, in, which case, someone will help them anyway and probably give a more or less the same answer as me.

I am not a Moderator though, so, my advice would be to click the "Flag bad post" and explain your situation (In enough details) and hopefully a Moderator will look at it and make a decision from there :)! IMO I would be happy with you changing your original post to just your (.h) class definitions since that's what I went off when helping you out :) Good luck with your assignment though.

phorce 131 Posting Whiz in Training Featured Poster

@L7Sqr

something that you are familiar with. Starting from scratch and expecting to be successful is not always the best approach.

I did my thesis on Signal Processing / Speech Recognition, something I hadn't even touched or researched before.. I get your point though, good advice :)!

phorce 131 Posting Whiz in Training Featured Poster

Hey,

Please can you mark this post as solved and give rep to those who helped you? (You can give rep by clicking the "up" arrow next to someones name).

As for your question related to deletion, it is very, very unlikly that your post/thread will be deleted, this is because DaniWeb is a resource forum in which members looking for help in this area can look back to this.

Could you tell me why it is bad that your full source code is up?

phorce 131 Posting Whiz in Training Featured Poster

unset the session to determine that someone is signed out? I.e. http://php.about.com/od/advancedphp/ss/php_sessions_3.htm

phorce 131 Posting Whiz in Training Featured Poster

Try this:

$value = .$row[booleanresult];
if ($value) { // if true
  $value = "YES";
} else {
  $value = "NO";
}
phorce 131 Posting Whiz in Training Featured Poster

@ralph1992 Please do ignore my last post, I've had a think about this.

Ok, what you're looking for is Association, nothing else, and nothing more. The fact your tutor wants this:

which can then be stored in one array.

Tells me that your instructor doesn't want you to have one ARRAY more as such as one ARRAY of OBJECTS. The method of Association is taught a lot in Colleges (I got taught this when I was at College..) ANYWAY..

I did an example, above somewhere that totally got ignored ;) so I'm guessing it confused the hell out of you. Not to worry, I have came up with another solution to show you exactly what I mean.

At the minute, you have an array of objects called Customers, an array of objects called "Accounts" and an array of objects called "Savings accounts" etc.. Our goal is to make all these objects, or, two objects become one array of objects, how we do this is to use Association, actually create an object of what you desire inside a class. (mhm?)

Let's see:

class Customer {

   public:

        Customer();
        Customer(int age, ..., ...);
        // Create another Constructor to allow for an object to be passed to it.
        Customer(int age, ..., ..., Account theA)
        {
            this->a = theA;
        }

        // create a member function to return "something"
        int getSomething()
        {
            return a.getSomething(); // we return the member function in "Account"
        }
    protected:

        Account a; // I have created an …
phorce 131 Posting Whiz in Training Featured Poster

Hey,

I think I get what you mean.. Look at it this way:

Customer <HAS>
   Account
   <Can be>
       Savings <or> Current

Let's say you have a customer:

Customer c(ID, NAME, ..., ...);

Customer c(1, "Phorce", ..., ...);

Now you would (in some way) have to link the ID to the customer, etc..

IF, however, you're creating the Objects all together, ok, so this way:

// create the customer, to have a savings, and current account
Customer c[1];
Account a[1];

for(int i=0; (i < 1); i++)
{
    c[i].makeAccount();
    a[i].makeAccount();
}

Then you can assume that c[0] HAS the account as a[0] thus infers that this can happen:

void Customer::showPersonsAccount(int customerNo)
{
   // remembering that CustomerNo is infact the number #id->place memory (set through "i")

   cout << c[i].returnName();
   cout << a[i].getAccountNumber();

}

You should find that the name, and the account number belongs to the same person that you created :)

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I don't know what you're doing here..

acnts[noOfAccounts].createAccount();

What are you storing noOfAccounts with?

Essentially, you're initalising an array of objects here:

Account* acnts[10]

So to access this, you would do this:

acnts[0].CreateAccount();

Here, look at this example:

#include <iostream>
#include <vector>

using namespace std;

class Account {

    public:
        Account()
        {

        }

        virtual void CreateAccount()
        {
            cout << "I have created an Account " << endl;
        }

};

class CurrentAccount : public Account {

    public:
        CurrentAccount()
        {

        }

        virtual void CreateAccount()
        {
            cout << "I have created a Current Account! " << endl;
        }
};


int main(int argc, char *argv[]) {
   Account *acnts = new Account[10];
   CurrentAccount *cAcnts = new CurrentAccount[10];

   acnts[0].CreateAccount();
   cAcnts[0].CreateAccount();
 }

but this stores them in 2 seperate arrays which I'm not allowed to do for the assignment :/

And I can't seem to grasp pointers :(

I don't understand this.. Stores what as two seperate arrays? Are they wanting you to create a 2D array? Essentially, a pointer is memory location over value.

P.S. I think this is what you mean by it:

int numberOfAccounts = 0;

cout << "Please enter the number of accounts you want to create";
cin >> numberOfAccounts;
for(int i=0; (i < numberOfAccounts); i++)
{
   acnts[i].CreateAccount();

}

BUT as I pointed out first, it is really bad to have inputs/outouts DIRECTLY inside the class functionality.

phorce 131 Posting Whiz in Training Featured Poster

i.e. how would a customer open a curre

i.e. how would a customer open a curre

Ok, so you know about Objects, right? Well if you had this:

Account a; // initalises an object of "Account"

CurrentAccount a; // Initalises an object of "CurrentAccount"

The thing is, through using association, if you know that a Customer HAS to make an Account with your system, and then they have the ability to make a current account, then what is the point in re-adding the data? The data is already there. (I believe):

Let me give you an example:

Account a(1, "Phorce", 150.00);
// my account number is 1, my name is Phorce and I'm very rich, I have £150+

Now I want a Current Account, it has a different number and you're going to give me £100 extra for making this as well as a intrest rate of 12%

Account a(1, "Phorce", 150.00); // Defined before
CurrentAccount c(10, 12, a); 

I have done a basic, basic example of this (I really do hope I haven't confused you) It's been a while since I have done association but have a look at this:

#include <iostream>

using namespace std;

class foo {

    public:
        foo() { }
        foo(int theAccountNo) {
             account_no = theAccountNo;
         }

        int getAccountNo()
        {
            return account_no;
        }
    protected:
        int account_no;


};

class bar : public foo {

    public:
        bar(int CURRENT_ACCOUNT_DETAILS) { current = CURRENT_ACCOUNT_DETAILS; }

        bar(int CURRENT_ACCOUNT_DETAILS, foo f) {

            current = …
phorce 131 Posting Whiz in Training Featured Poster

Are you asking how to implement inheritence?

If so, such tasks take place primarly in your class definitions (.h) files, so, might be an idea to post them over the class implementation (.cpp). IMO.

I don't get it though because inheritence usually has a "IS A", "CAN BE" Are you sure you don't mean association? ("HAS A") so therefore..

CUSTOMER
<has a>
CurrentAccount

?

Also, look at this:

void Customer::addNewCustomer()
{
    cout << "Enter your name > ";
    getline(cin,name);
    cout << "Enter your Address: ";      
    getline(cin,address);
    cout << "Enter your telephone number: ";  
    getline(cin,telNo);
    cout << "Enter your sex: ";    
    getline(cin,sex);
    cout << "Enter your Age: ";   
    cin >> age;
}

Avoid putting inputs / outputs in the class. Think about if you wanted to output this code in a different way than just console... It wouldn't work.

phorce 131 Posting Whiz in Training Featured Poster

So i'm confused.. Is this a troll post?

phorce 131 Posting Whiz in Training Featured Poster

Yeah, I don't see any other way than what @myk45 said. It's a static variable, meaning it's scope is the class only.

phorce 131 Posting Whiz in Training Featured Poster

Women, mostly.

And forums like DaniWeb. Oh, and errors. Errors distract me a lot, I can get really annoyed and then leave it for up to a week sometimes.. It's bad!

phorce 131 Posting Whiz in Training Featured Poster

But the code I have used does not work to write/save the data to the array.

What?

phorce 131 Posting Whiz in Training Featured Poster

For one, don't use:

#include <iostream.h> // this is bad

// use this

#include <iostream>



// Don't use:

void main()
{

}

// Use:

int main()
{

}

You can't expect to use: cout, cin etc.. without declaring you're using the std namespace, so, before your "main" function, always put this:

using namespace std;

I don't get why you ask, and get the user to input an "Array size" but never actually use the value to re-size the array.. mhm weird!

ALSO, in some of your for loops you have this:

for(i ......)
{

}

But you don't actually declare what i is, so therefore:

for(int i=0, ...., ...)
{

}

Don't just copy the code I have re-written, compare it to yours, and, see where you went wrong, why your's was not compiling..
Ok, here is your code re-written:

#include <iostream>

using namespace std;

int main()
{
    int a[50][50];
    int r, c, ans = 0;

    cout << "Enter Array Size: ";
    cin >> r;

    for (int i=0;i<r;i++)
    {
         for (int j=0;j<c;j++)
         {
            cin>>a[i][j];
         }
    }


    cin.get();

    for (int i=0;i<r;i++)
    {
        for (int j=0;j<r;j++)
        {
           cout<<a[i][j];
        }
        cout << endl;
    }

    cout << endl << endl;
    for (int i=0;i<r;i++)
    {
        ans=ans+a[i][i];
    }
        for (int i=(r-1);i>=0;i--)
        {
            ans = ans+a[r-i-1][i];
        }
        if (r % 2!=0)
        {
            ans=ans-a[(r-1)/2][(r-1)/2];
        }
        cout<<"Sum of Diagonal Elements is:"<<ans;
        cin.get();



}
phorce 131 Posting Whiz in Training Featured Poster

What the hell is this:

// new averaging system
float pp;
float x;
float xx;
float xxx;
float xxxx;
float xxxxx;
float xxxxxx;
float xxxxxxx;
float xxxxxxxx;
float xxxxxxxxx;
float xxxxxxxxxx;
float xxxxxxxxxxx;
float xxxxxxxxxxxx;
float xxxxxxxxxxxxx;
float xxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxxx;
float xxxxxxxxxxxxxxxxxxxx;

If that is the "new averaging system" then I would hate to see the old one!

phorce 131 Posting Whiz in Training Featured Poster

Why not have an array of theme colours ("colors") and then people who have bought subscription can then use a hex code to have any colour of their choice? :D

just throwing it out there!!

phorce 131 Posting Whiz in Training Featured Poster

No problem - Is there anything specific that confuses you?

phorce 131 Posting Whiz in Training Featured Poster

Good luck with it :)! Remember to mark this as solved, and give rep ;)!

phorce 131 Posting Whiz in Training Featured Poster

Ok, so I'm confused now!!

You basically want to send a variable to a function and then for that variable to do something inside the function? Why is it returning an int then? -confused-

Something like this?

void zonePick(int theZone);
void zone1();
int main()
{
    int zone;

    cout << "Please enter which zone you'd like to go to: ";
    cin >> zone;

    zonePick(zone);
}


void zonePick(int theZone)
{
    // in this function then, we can do something with zone

    switch(theZone)
    {
        case 1:
            cout << "ZONE 1";
            zone1();
        break;    

        default: cout << "Zone doesn't exist";
    }

}

void zone1()
{
    // DO SOMETHING IN ZONE 1

}
phorce 131 Posting Whiz in Training Featured Poster

Your implementation of function definition is wrong:

int zonePick(int foo); // class definition (prototype)

The implementation should be the same:

int zonePick(int foo)
{

}

This also assumes that you're passing a variable, or a value to it:

int zonePick(int foo);

int main()
{
    int foo = 10;

    int valueReturnedFromFunction = zonePick(foo); // will store 100 in this variable

    cout << valueReturnedFromFunction << endl;
}

int zonePick(int foo)
{
   // here's an example
   return (foo * 10);
}

Hope this helps a bit :)

phorce 131 Posting Whiz in Training Featured Poster

Ok, well at this stage you can compare the values that are inputted from the user:

int main()
{

    int shape;

    cout << "What shape do you want: ";
    cin >> shape;

    if(shape == 0)
    {
       // triangle
    }

    if(shape == 1)
    {
       // square 
    }
}

This is good:

typedef unsigned short USHORT;

More effective than using:

ushort s = FOOOO;

:) Good luck!

phorce 131 Posting Whiz in Training Featured Poster

Yeah @LastMitch is right, MYSQLI is easier to manage.

I read somewhere that PDO means that you do not have to worry about SQL injection I don't know how true this is though

phorce 131 Posting Whiz in Training Featured Poster

So basically:

I'm guessing by this line:

USHORT triangle, square, rectangle, circle;

You're defining variables which can then be compareable, why?

Also, your comparision is wrong, like this:

if (shape = triangle)
{
    ...
}

A single "=" indicates to the compiler that you are trying to initalise a variable with a value:

int age = 10; // I've set age to 10

So we use DOUBLE "==" in order to make a comparision of EQUAL TO.

Which brings me onto my next point, why are you using if statements for this? Ok, I guess you can, but, surely it would be better / more effective just to use switch statements? Let me give you an example:

switch(shape)
{
    case 0:

        // code for triangle

    break;

    case 1:

       // code for square
    break;

    // OTHER CASES

    default:

       cout << "Your option was unknown";
}

You're on the right track, I just think you're going about this problem the wrong way!

ALSO with the sides, why are these values not an array? Instead of writing:

int side1;
int side2;
int side3;

That's not a good programming technique!

phorce 131 Posting Whiz in Training Featured Poster

Why so?

I think anything with complex search algorithms that requires in-depth lexical analysis is complicated, so like Google!

phorce 131 Posting Whiz in Training Featured Poster

Should your class name be called "list"...?

phorce 131 Posting Whiz in Training Featured Poster

Ok, I kind of know what it is you're trying to achieve.

If you're wanting it so when a user types a key down it comes up with suggestions, this is quite simply.. It is done with jQuery/Ajax =)

To do the recommended searches is a little more complex, will require PHP/PERL etc and a database also an algorithm =)!

phorce 131 Posting Whiz in Training Featured Poster

This is not complicated at all, THINK about it!

1) Input values into an array that are above "0":

input = {1, 2, ..., 2, 3, .. 9,> 0};

2) Check to see if input (at the given time) is "0"

   if this value is not greater than 0 
   then
       check to see if the values of the array are even
       if true, then->
          initalise sum = 0;
          sum += value[x] // x representing the location at the given time
       end
   end

Something like this =) Here, look at this example code, to give you a clear understanding:

#include <iostream>
#include <vector>

using namespace std;

double summationOfEven(vector<int> &nums)
{
    int sum = 0;

    for(unsigned i=0; (i < nums.size()); i++)
    {
        if(nums[i] % 2 == 0)
        {
            sum += nums[i];
        }
    }

    return sum;
}
int main(int argc, char *argv[]) {

    vector<int> numbers;

    bool isSet = false;

    while(!isSet)
    {
        int num = 0;

        cout << "Please enter a number: ";
        cin >> num;

        numbers.push_back(num);

        if(num == 0)
          isSet = true;
    }

    cout << summationOfEven(numbers);
}

Output:

Please enter a number: 2
Please enter a number: 4
Please enter a number: 6
Please enter a number: 8
Please enter a number: 5
Please enter a number: 0
20

phorce 131 Posting Whiz in Training Featured Poster

@dran.ong.14 - Be greatful that people are taking time out of their busy lives to help you, rather than being forward and asking someone to literally spoon-feed you the fix.

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I tried to run the code you've posted and it shows an indentation error. Is this the way that DaniWeb has formatted it, or, is it your code?

I don't get what you're trying to ask, is your question regarding the fact that "random" cannot be imported, or, to do with the random function? Please POST the ERROR message that you get (if any) :)

phorce 131 Posting Whiz in Training Featured Poster

L7Sqr I like this implementation actually :)!

Would this allow me to create a Singleton though? For example, it looks like I can create multiple objects so I need a way that only ONE object can be created?

phorce 131 Posting Whiz in Training Featured Poster

Thank you for both of your replies :)!

Basically, I managed (after a lot of shouting and banging things!) to get this working, and it does the expected output BUT I am just wondering if this is the best implementation for such a singleton problem?

#include <iostream>
using namespace std;

class Animal {

    public:
        virtual int age() = 0;
        virtual void speak() = 0;
};

class Cat : public Animal
{
    public:
            int age() { return 4; }
            void speak() { cout << "MEOW"; }

};

class Dog : public Animal {

    public:
       age() { return 4; }
       void speak() { cout << "WOOF!!"; }


};

class Horse : public Animal {

    public:
        int age() { return 4; }
        void speak() {cout << "MERRR"; }

};

class Singleton
{
    public:
        Animal *newAnimal(string theTypeOfAnimal);

        static Singleton *instance()
        {
            static Singleton instance;
            return &instance;
        }
      private:      
      static Animal* pinstance;
};

Animal* Singleton::pinstance = 0;


Animal *Singleton::newAnimal(string theTypeOfAnimal)
{
    if(theTypeOfAnimal == "Cat")
    {
        this->pinstance = new Cat;
    }else if(theTypeOfAnimal == "Dog")
    {
        this->pinstance = new Dog;

    }else if(theTypeOfAnimal == "Horse")
    {
        this->pinstance = new Horse;
    }
    return pinstance;
}  

int main(int argc, char *argv[]) {

    //Animal *pAnimal = NULL;

    Animal *pAnimal = Singleton::instance()->newAnimal("Horse");

    cout << pAnimal->age() << endl;
    pAnimal->speak();


}

Thank you again for the help :)!

phorce 131 Posting Whiz in Training Featured Poster

Hello,

So basically, I am trying to create a system based on the Singleton Pattern and I'm confused.

If I have an Animal class, as well as a Cat class which is derived from Animal and then using a Singleton class will create a single object of which-ever class has been selected (dog, horse, cat etc..):

Animal.h

class Animal {

    public:
        virtual int age() = 0;
        virtual void breed() = 0;   
};       

Cat.h

#include "Animal.h"

class Cat : public Animal {
  public:
    Cat();
    int age();
    void breed();  
};

Cat.cpp

Cat::Cat(){};

int Cat::age()
{
    return 10; 
}
void Cat::breed()
{


}      

Singleton.h

#include "Animal.h"    
#include <iostream>

using namespace std; 

class Singleton 
{
    private: 
        static bool instanceFlag;
        static Singleton *single;
        Singleton()
        {

        }
    public:
        static Singleton* getInstance();
        Animal *method(string something);
        ~Singleton()
        {
            instanceFlag = false;
        }   


};

Singleton.cpp

#include "Singleton.h"
#include <iostream>

using namespace std;

bool Singleton::instanceFlag = false;
Singleton* Singleton::single = NULL;

Singleton* Singleton::getInstance()
{
    if(!instanceFlag)
    {
       single = new Singleton();
       instanceFlag = true;
       return single;
    }else{
      return single;
    }  
}    

Animal *Singleton::method(string something)
{
    if(something == "cat")
    {
       // new Cat instance
    } 
    // etc
}

main.cpp

#include <iostream>
#include "Singleton.h"
using namespace std;    


int main()
{        

    Singleton *sc1;
    sc1 = Singleton::getInstance();
    sc1->method("Cat");
    return 0;
}

Anyone know where I am going wrong? Why I can't create a new Cat and call it's methods...?

Any help would be amazing :)!