473,796 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is wrong with this declaration ?

Hi,

I want to declare a variable of type (Vector of pairs) - Ok, I know this
can be done using a map, but I want to keep things simple for now.

I have declared the variable as ff in this code snippet:
#pragma once
#include <string>
#include <utility>
#include <map>

using namespace std;

vector<pair <int, int>> linePairs ; // <- compiler cringes here

Compiler err messages are as ff:

syntax error : missing ';' before '<'
'Script::vector ' : missing storage-class or type specifiers
expecting '>' to terminate template-argument-list, found '>>'
unexpected token(s) preceding ';'

Any pointers (no pun intended !) would be much appreciated.

Jul 23 '05
24 1453


Alf P. Steinbach wrote:
* Susan Baker:
[top-posting]

Please don't top-post in this group, see the FAQ, corrected.
* Susan Baker:
#pragma once
#include <string>
#include <utility>
#include <map>

Needs to #include <vector> here.

using namespace std;

vector<pai r <int, int>> linePairs ; // <- compiler cringes here

^ Needs an extra space here.
This is a "fuller" snippet of code:

#pragma once

#include <string>
#include <utility>
#include <map>

Needs to #include <vector> here.
using namespace std;

class Script
{
private:
string name ;
string source_code ;
vector< pair <int, int> linePairs; // <- compiler dosen't like this

^ Needs a right angle bracket '>' here.

Btw., if this is a header file then it's not a good idea to have
'using namespace std;' there. If it's an implementation file then
it's OK. Reason: you don't want to force all the names in the std
namespace on clients of the header file.

Also, be aware that '#pragma once' is a non-standard language extension,
although a very common one.

In standard C++ you'd use a header file guard, like

#ifndef SCRIPT_H
#define SCRIPT_H
// ... Contents of header file [script.h] here.
#endif

and many/most compilers recognize this pattern so that they can optimize
their file handling (subsequently they'll avoid opening this file).


Many thanks Alf - it was the missing header file "who dunnit". It's
always the simplest things that get overlooked - many thanks once again.

Jul 23 '05 #11
Susan Baker wrote:

Susan, *please* don't top-post - you've already been
asked politely once.

[rearranged]
Torsten Mueller wrote:
Susan Baker <sb****@no.spam .net> schrieb:

vector<pair <int, int>> linePairs ; // <- compiler cringes here

use

vector<pair <int,int> > linePairs;
^
this space is relevant

Nope, still not compiling ... (thanks anyway)


Why is it not compiling? What does the compiler say? What
code exactly doesn't compile?

It's generally a very good idea to include a *complete* (minimal,
potentially compilable) program - just cut and paste your code.
That way we can reproduce your problem and help you to solve it.

Help us to help you :-)

FWIW, this (complete) program compiles fine for me:

// start test.cpp

#include <utility>
#include <vector>

int main()
{
std::vector<std ::pair<int,int> > linePairs;
return 0;
}

// end test.cpp

Regards,

--
Lionel B

Jul 23 '05 #12


Lionel B wrote:
Susan Baker wrote:

Susan, *please* don't top-post - you've already been
asked politely once.

[rearranged]

Torsten Mueller wrote:

Susan Baker <sb****@no.spam .net> schrieb:

vector<pa ir <int, int>> linePairs ; // <- compiler cringes here
use

vector<pair <int,int> > linePairs;
^
this space is relevant


Nope, still not compiling ... (thanks anyway)

Why is it not compiling? What does the compiler say? What
code exactly doesn't compile?

It's generally a very good idea to include a *complete* (minimal,
potentially compilable) program - just cut and paste your code.
That way we can reproduce your problem and help you to solve it.

Help us to help you :-)

FWIW, this (complete) program compiles fine for me:

// start test.cpp

#include <utility>
#include <vector>

int main()
{
std::vector<std ::pair<int,int> > linePairs;
return 0;
}

// end test.cpp

Regards,


Thanks Lionel, it was an emabarassingly simple case of me forgetting to
#include <vector>, as pointed out by Alf. I'm afraid the templated
parameters were a bit of a red herring.

PS: I did not top post since Alf alerted me to this ng's netiquette.
please check the posting times.

Jul 23 '05 #13
"Simon" <sp********@exa mple.com> schrieb:
All the posts that are trying to point where you should have a space
assume your newsreader settings are the same as theirs.


No, surely not. But using a monospace font rather than a proportional
font should be a rule (!) while reading news, especially in a news
group handling a programming language. However, Outlook people tend to
forget that there has been an outer world before.

T.M.
Jul 23 '05 #14
>
All the posts that are trying to point where you should have a space
assume your newsreader settings are the same as theirs.
No, surely not. But using a monospace font rather than a proportional
font should be a rule (!) while reading news, especially in a news
group handling a programming language. However, Outlook people tend to
forget that there has been an outer world before.


So what are you saying?
Because my settings are not moonscape I am a new plague to the programming
world?

Is using a computer forgetting that their was an outer world?

I accept your settings, and you should accept mine.

T.M.


Simon
Jul 23 '05 #15
Because my settings are not moonscape I am a new plague to the programming


Sorry, "monospace" , this outlook spell checker is a real pain. I only wish
the outer world would teach me how to type again.

Simon
Jul 23 '05 #16
Susan Baker wrote:
Lionel B wrote:
/.../
It's generally a very good idea to include a *complete* (minimal,
potentially compilable) program - just cut and paste your code.
That way we can reproduce your problem and help you to solve it.


/.../
Thanks Lionel, it was an emabarassingly simple case of me forgetting
to #include <vector>, as pointed out by Alf. I'm afraid the templated
parameters were a bit of a red herring.
That demonstrates rather nicely the point I was making of posting real
complete code - if you had done so originally your error would have been
spotted straight away.
PS: I did not top post since Alf alerted me to this ng's netiquette.
please check the posting times.


Yes, our mails crossed in the post...

Good luck,

--
Lionel B

Jul 23 '05 #17
"Simon" <sp********@exa mple.com> schrieb:
All the posts that are trying to point where you should have a
space assume your newsreader settings are the same as theirs.
No, surely not. But using a monospace font rather than a
proportional font should be a rule (!) while reading news,
especially in a news group handling a programming language.
However, Outlook people tend to forget that there has been an
outer world before.


So what are you saying? Because my settings are not moonscape I am a
new plague to the programming world?


You can name your own as you want.
Is using a computer forgetting that their was an outer world?
I tried to relativate your opinion, most of the readers see wrong
positions pointed to by my pointer. Indeed most of the Outlook Express
users will have wrong positions because they never did setup a
monospace font using still the default proportional one. I don't know
*any* other news reader using a proportional font by default.
I accept your settings, and you should accept mine.


I accept whatever software you use and whatever you configure (or
not). But using a proportional font in a news group is *your* own home
made problem, not mine.

T.M.
Jul 23 '05 #18
"Simon" <sp********@exa mple.com> write:
All the posts that are trying to point where you should have a
space assume your newsreader settings are the same as theirs.
No, surely not. But using a monospace font rather than a
proportional font should be a rule (!) while reading news,
especially in a news group handling a programming language.
However, Outlook people tend to forget that there has been an
outer world before.


So what are you saying? Because my settings are not moonscape I am a
new plague to the programming world?


You can name yourself as you want.
Is using a computer forgetting that their was an outer world?
I tried to relativate your opinion, most of the readers see wrong
positions pointed to by my pointer. Indeed most of the Outlook Express
users will have wrong positions because they never did configure a
monospace font. So they use still the default proportional font. I
don't know *any* other news reader using a proportional font by
default.
I accept your settings, and you should accept mine.


I accept whatever software you use and whatever you configure (or
not). But using a proportional font in a news group is *your* own home
made problem, not mine.

T.M.

BTW: You could configure at least a charset.
Jul 23 '05 #19
>
I tried to relativate your opinion, most of the readers see wrong
positions pointed to by my pointer. Indeed most of the Outlook Express
users will have wrong positions because they never did configure a
monospace font. So they use still the default proportional font. I
don't know *any* other news reader using a proportional font by
default.
It may be so, but an easy way around is to simply not assume that the whole
world is right, (monospace).
And use a simple alternative.
Computers have evolved enough to allow different fonts, assuming that we all
use the same as you is simply not the answer.
I accept your settings, and you should accept mine.


I accept whatever software you use and whatever you configure (or
not). But using a proportional font in a news group is *your* own home
made problem, not mine.


What a great attitude to have around the internet.
"It's my way, and any other way is your problem"

T.M.

BTW: You could configure at least a charset.


Why on earth would I do that?

Simon
Jul 23 '05 #20

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

Similar topics

2
2059
by: Sylvain Thenault | last post by:
Hi there ! I've noticed the following problem with python >= 2.3 (actually 2.3.4 and 2.4): syt@musca:test$ python Python 2.3.4 (#2, Sep 24 2004, 08:39:09) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import parser >>> parser.suite('# -*- coding: IBO-8859-1 -*-')
15
2462
by: M.Siler | last post by:
<HTML> <HEAD> <TITLE></TITLE> <SCRIPT> <!-- var factor_val = new Array(8,7) factor_val = 68.8 factor_val = 55
20
2570
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as following, delimited by //////: ////////////////pose.h #ifndef pose_h #define pose_h #include "point.h"
11
2235
by: Dart | last post by:
This code is okay: class CSingle { public: static CSingle membs; int MEM_NUM; CSingle(int n) { }
28
3281
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr(); fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
9
1663
by: Curious Student | last post by:
Some places till now, I've seen function prototypes within functions instead of in the global declaration space, which I thought was the way. I thought it was <I>only</I>: int myfunction(int, int); int main(void) {
10
2363
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and begun to use GNU Autotools. I'm sorry to say I'm new to gcc as well :( Now I get the most ridiculous compile error which I'm unable to solve. Can someone, please, help me with this? gcc output together with the files mentioned in the gcc error...
7
6279
by: arun_shamli | last post by:
class CDate { public: CDate() {} CDate(const CDate& date) {} }; CDate function1() { CDate date(); return date;
15
9049
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str, &endptr, 10); printf("errno=%d\n", errno);
7
4271
by: mosfet | last post by:
HI, when trying to compile an embedded version of STL called ustl on win32 platform I get the following error : /// Returns the minimum of \p a and \p b template <typename T1, typename T2> inline const T1 min (const T1& a, const T2& b) { return (a < b ? a : b);
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.