Help with simple script

I cant get this script to work.

Im sure it's because char does not work as strings do. But for my school project I need to make this script with chars (can't use strings, because I need to learn how chars work).
As I've understood from the script is that, the compiler does not know what index number all the flights command will get. Like flights[0] = (hi, hello); and flights[1] = (hows it, going);
With strings and vectors its much more easy when you can add push.back that handles that for you etc.
But how do I get this to work with chars? Anybody? :P

Thanks in advance

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
#include <iostream>

using namespace std;

class Flight
{
public:
	char name;
	char model;

	Flight(char _name, char _model)
	{
		name = _name;
		model = _model;
	}
};

int main()
{
	Flight* flights[10];
	char names;
	char models;

	cout << "N\x84mn en film du vill l\x84gga till: " << endl;
	cin >> names;
	cout << "skriv n\x86got mer: " << endl;
	cin >> models;
	Flight(names, models);
	for (int i = 0; i < 1 ; i++)
	{
		cout << Flight[i].name << endl;
	}
	
}
flights is an array of ten pointer-to-Flight. Those pointers don't point to anything so actually you don't have any Flight object.

On line 28 you're creating a Flight object, but it isn't assigned to any variable and is forever lost.

On line 31 you're trying to index a type name, which doesn't make sense. You want to index the array of Flight objects.
Thank you for the reply! Problem is that I actually don't know what to change to make the flights array to actually make those poitns to "point" at something.
I usually use vectors and strings and its SO much easier! Though this is for my school project and im stuck :(
Any ideas of what I could change, if it's possible to write this way?
If you can't use an array of simple objects then you need to new the flights.
http://www.cplusplus.com/doc/tutorial/dynamic/
Topic archived. No new replies allowed.