why this code is not working ??

i am using visual C++ 2010 i m having just one error i want user to enter inputs model and color and then it will pass to a public variable and public member function will access private data members and assign values to it then a public member function will display those values main.when i try to write s1.colr[10] to pass it to fuunction it gives error.

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
   #include<iostream>
using namespace std;
#include<conio.h>

class vehicle
{
private:
	
	int modelnumber;
	char color[10];
	
public:
	
	
		void get_input()
		{
			
			cout<<"Enter Model nummber=";
			cin>>modelnumber;
			cout<<"Enter Color=";
			cin>>color;
		}
	void disp()
	{
		cout<<"Model Number Is:"<<modelnumber ;
		cout<<endl;
		cout<<"Color Is:"<<color;
		cout<<endl;
		
	}	
};
	int main()
	{
		vehicle s1;
		s1.get_input();
	s1.disp();
	getch();
	
	}		


Wellllll,,,Thanks Guys i did it my self ... i m much sad so little help ..but anyway thanks .this code is edited and works fine
Last edited on
i m having just one error


What is the error?
s1.colr[10] is past the end of your array; the valid elements are s1.colr[0] to s1.colr[9].

It doesn't seem like you understand how arrays work; I recommend re-reading whatever material you are using to learn since you try to use s1.colr[10] to refer to, apparently, "the whole array" in many places, which does not work.
now edited the code tell me what to put inside array braces while passing it function
Topic archived. No new replies allowed.