473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reason of error?

Hi

Why this code is giving me an error. If I uncomment the commented line
and make my structure global it work fine.

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
// struct student{
// char name[20];
//int rollno;
//};
int main(int argc, char *argv[])
{
struct student{
char name[20];
int rollno;
};
vector<struct student>stu;

system("PAUSE");
return 0;
}

Regards
Mayank Jain(Nawals)

Aug 20 '07 #1
2 1206
On Aug 20, 9:59 pm, "contactmayankj...@gmail.com"
<contactmayankj...@gmail.comwrote:
Hi

Why this code is giving me an error. If I uncomment the commented line
and make my structure global it work fine.

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
// struct student{
// char name[20];
//int rollno;
//};
int main(int argc, char *argv[])
{
struct student{
char name[20];
int rollno;
};
vector<struct student>stu;

system("PAUSE");
return 0;

}

C++ standard 14.3.1 (2) : A local type ... shall not be used as a
template argument or a template type parameter

Since student is a local class, using it as template argument for
std::vector is not allowed

-N

Aug 20 '07 #2
co***************@gmail.com wrote:
Why this code is giving me an error. If I uncomment the commented line
and make my structure global it work fine.

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;
// struct student{
// char name[20];
//int rollno;
//};
int main(int argc, char *argv[])
{
struct student{
char name[20];
int rollno;
};
vector<struct student>stu;

system("PAUSE");
return 0;
}

Regards
Mayank Jain(Nawals)
First off, please read the FAQ 5.8. It helps to supply _all_ the
information you can, for example, *what* error you get. Have you
read the error message? What in it do you not understand? See,
without actually knowing what the error message says, we can't help
you by explaining it.

I will venture a guess that your compiler complains because you're
not allowed to use local classes as template arguments. Local
classes don't have linkage and as such are prohibited from use in
template (according to the current standard).

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefano Tesini | last post by:
Hi all, when i drop a table, i take his error : SQL0902C System error (REASON CODE = "122"). Why ? Ver UDB Server nt 7.1.0 Ver UDB Cli 7.1.0 Win 98 or XP the error is the same.
3
by: Eveline | last post by:
Dear all, I have a database on which I do stuff like: - creating tables - filling those tables with data - joining tables - EXPORT of queries to file - LOAD data from file into a tables
4
by: acemann7 | last post by:
Windows 2000 udb v 7.2 Got the latest fixpak 13 Applied it. Still can't get a single java sp to run. I used to get reason "2"... now reason "0" - reason 0 is not even documented. I point...
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
3
by: JPARKER | last post by:
Our DB2 8.2 FixPak9 database running on Win2K crashed with after reporting this message SQL0902C A system error (reason code = 9") ocurred I have searched the DB2 documentation as well as the...
4
by: jason.awlt | last post by:
Greetings, I recently being bugged by the following error on my DB2. SQL0902C SQLSTATE = 58005 Reason Code = 14 This error comes out everytime i tried to insert some record to a table...
9
by: shorti | last post by:
db2 V8.2 I have been looking for a good way to log the 'reason code' when we hit an sqlcode that uses them. From what I can tell the reason code is stored in sqlca.sqlerrmc. But, there seems...
8
by: Challenge | last post by:
Hi, I got error, SQL1768N Unable to start HADR. Reason code = "7", when I tried to start hadr primary database. Here are the hadr configuration of my primary db: HADR database role ...
0
by: Amarkumar Gopa | last post by:
Hi, I am getting the Db2 error -804. Some times, I am getting reason code 06 and some times 07. There is no change in the application program. Do you help me in identifying this error. ...
1
by: Rudolf Bargholz | last post by:
Hi, We have created triggers to log modifications to tables in our application. The triggers work fine, just on one of the tables in our database the triggers fail with the error message...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.