NEWBIE XCODE ERROR

Hi, im new too c++ and im writing a simple program that takes a tires make, size, cast etc. And prints out a few calculated results. I wrote the program on xcode it complies but when i run it it stops half way though and gives me a 11db error? When i try to debug it works fine and help please?
#include <iostream>

using namespace std;

class tire{

protected:
const char * make;
double cost, price;
int size;

public:
tire(const char * mk, double cst, int size);

virtual void set_price() { price = cost * 1.06;}
double get_price() { return price;}
const char * get_make() { return make;}
int get_size() {return size;}


};







ostream& operator<<(ostream& os, tire& x)
{
os << x.get_make() << endl;
return os;
}










class winter_tire: public tire
{

private:
double mounting_cost;



public:
winter_tire(int sz,const char * mk, double cst = 165.00, double mntg_cst = 26.00) : tire(mk, cst, sz)
{
cost = cst;
mounting_cost = mntg_cst;
size = sz;
make = mk;
}

void set_price() { price = mounting_cost + (1.04 * cost);}

//friend ostream& operator<<(ostream& os, winter_tire& x)
//{
// os << x.get_price() << endl;
// return os;
//}

};









tire::tire(const char * mk, double cst = 125.00, int sz = 2356018): size(sz)
{
cost = cst;
size = sz;
make = mk;
}








int main()
{
tire gangster("hey",10.00, 5);
cout << gangster << endl;

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>

class tire
{
    protected:
        std::string make; // http://www.mochima.com/tutorials/strings.html
        double cost, price;
        int size;

    public:
        tire( const char* mk, double cst, int size ) : make(mk), cost(cst), size(size)
        { price = cost * 1.06 ; }

        // virtual void set_price() { price = cost * 1.06;}

        // http://www.parashift.com/c++-faq-lite/const-member-fns.html
        virtual double get_price() const { return price;}
        virtual std::string get_make() const { return make;}
        virtual int get_size() const {return size;}
};

// http://www.parashift.com/c++-faq-lite/overview-const.html
std::ostream& operator<<( std::ostream& os, const tire& x )
{
    os << x.get_make() << " (price:" << x.get_price() << ")\n";
    return os;
}

class winter_tire: public tire
{
    private:
        double mounting_cost;

    public:
        winter_tire( int sz, const char* mk, double cst = 165.00, double mntg_cst = 26.00 ) : tire( mk, cst, sz )
        {
            mounting_cost = mntg_cst;
            price = mounting_cost + ( 1.04 * cost );
        }
};

int main()
{
    tire gangster( "hey", 10.00, 5 );
    std::cout << gangster << '\n' ;

    winter_tire gangster2( 5, "hey2", 10.00 );
    std::cout << gangster2 << '\n' ;
}

http://coliru.stacked-crooked.com/a/8c0e85cbcc767237
What was wrong with my code? And i cant really use all of this because i need it in the format i made it in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <string>
using namespace std;

class tire
{
    protected:
        std::string make; // http://www.mochima.com/tutorials/strings.html
        double cost, price;
        int size;

    public:
        tire( const char* mk, double cst, int size ) : make(mk), cost(cst), size(size)
        { price = cost * 1.06 ; }

        // virtual void set_price() { price = cost * 1.06;}

        // http://www.parashift.com/c++-faq-lite/const-member-fns.html
        virtual double get_price() const { return price;}
        virtual std::string get_make() const { return make;}
        virtual int get_size() const {return size;}
};







ostream& operator<<( std::ostream& os, const tire& x )
{
    os << x.get_make() << " (price:" << x.get_price() << ")\n";
    return os;
}










class winter_tire: public tire
{
    private:
        double mounting_cost;

    public:
        winter_tire( int sz, const char* mk, double cst = 165.00, double mntg_cst = 26.00 ) : tire( mk, cst, sz )
        {
            mounting_cost = mntg_cst;
            price = mounting_cost + ( 1.04 * cost );
        }
};









int main()
{
    tire gangster( "hey", 10.00, 5 );
    std::cout << gangster << '\n' ;

    winter_tire gangster2( 5, "hey2", 10.00 );
    std::cout << gangster2 << '\n' ;
}
Topic archived. No new replies allowed.