-5

When I run the following C++ code, got the compilation error like- Type 'array' may not be defined here in line 17.

#include<iostream.h>
class array
{
char a[10][10];
public:
array()
{
   a[10][10]='h';
}
void print()
{
     cout<<(a[0]==*a)&&(*a==0[a]);``
}
 }
 main()
{
array ob;
ob.print();

 }

I tried my best to resolve this error, but not succeeded, please suggest the solution. Thanks in advance.

user2267023
  • 37
  • 2
  • 8
  • Is that `\`\`` at the end of the `cout` line in your actual code, or did this happen trying to format the code on SO? – jwueller Dec 10 '13 at 19:24
  • In the `array` constructor, you are accessing past the array. Array indices are zero based, meaning they go from 0 to (capacity - 1). – Thomas Matthews Dec 10 '13 at 19:25
  • 5
    Please, do a favour to yourself and read a [decent book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list?rq=1) instead of some half-baked tutorials. This is terrible. – Sceptical Jule Dec 10 '13 at 19:27

1 Answers1

7

You forgot the trailing ; after your class definition and to declare int as the return type for main.

Also, the correct header to include is <iostream>, not <iostream.h>.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625