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. 24 1408
Susan Baker wrote: vector<pair <int, int>> linePairs ; // <- compiler cringes here
^--- insert a space just here
vector<pair <int, int> > linePairs;
Mathias
This is a "fuller" snippet of code:
#pragma once
#include <string>
#include <utility>
#include <map>
using namespace std;
class Script
{
private:
string name ;
string source_code ;
vector< pair <int, int> linePairs; // <- compiler dosen't like this
.........
Susan Baker wrote: 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.
The issue is that '>>' is an operator. You need to add a space:
vector<pair <int, int> > linePairs ;
You also need to include <vector>
Hi Mathias,
Thanks for the tip - unfortunately, I tried it and still no joy...
Mathias Waack wrote: Susan Baker wrote:
vector<pair <int, int>> linePairs ; // <- compiler cringes here
^--- insert a space just here vector<pair <int, int> > linePairs;
Mathias
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
T.M.
Looks like Mathias didn't point to the exact position. Just break your >>
into >[space]> where [space] means what you get when you hit the space bar.
ben
"Susan Baker" <sb****@no.spam.net> wrote in message
news:da**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com... Hi Mathias,
Thanks for the tip - unfortunately, I tried it and still no joy...
Mathias Waack wrote:
Susan Baker wrote:
vector<pair <int, int>> linePairs ; // <- compiler cringes here
^--- insert a space just here vector<pair <int, int> > linePairs;
Mathias
Nope, still not compiling ... (thanks anyway)
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
T.M.
* 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<pair <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).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? Nope, still not compiling ... (thanks anyway)
Torsten Mueller wrote:
All the posts that are trying to point where you should have a space assume
your newsreader settings are the same as theirs.
Almost all of them are pointing at the wrong place, yet they all mean the
same.
vector<pair <int, int>> linePairs ; // Your code
vector<pair <int, int> > linePairs ; // Note the space after ...int> > ...
Because >>, (no space), means something else so you must add the space so
the compiler doesn't get confused.
Simon
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<pair <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.
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
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<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,
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.
"Simon" <sp********@example.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.
> 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 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
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
"Simon" <sp********@example.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.
"Simon" <sp********@example.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.
> 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
"Simon" <sp********@example.com> schrieb: BTW: You could configure at least a charset.
Why on earth would I do that?
I said "You could". Of course you will not, I know.
T.M. > BTW: You could configure at least a charset. Why on earth would I do that?
I said "You could". Of course you will not, I know.
And I said, (amongst other things), why would I want to do that? T.M.
Simon
Susan Baker wrote: This is a "fuller" snippet of code:
#pragma once
#include <string> #include <utility> #include <map>
using namespace std;
class Script { private: string name ; string source_code ; vector< pair <int, int> linePairs; // <- compiler dosen't like this
(a) don't top-post
(b) the closing angle bracket is missing. ........
Torsten Mueller <de******@shared-files.de> wrote in
news:u3***********@fastmail.fm: 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.
Actually XNews defaults to a proportional font when reading (but not when
writing, go figure...). However it does have a button to click to change
to a non-proportional font at will...
i have to admit monospace makes reading a lot tiring. Even Bjarne doesn't
use monospace fonts in his book.
ben This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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",...
|
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
|
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...
|
by: Dart |
last post by:
This code is okay:
class CSingle
{
public:
static CSingle membs;
int MEM_NUM;
CSingle(int n)
{
}
|
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();...
|
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,...
|
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...
|
by: arun_shamli |
last post by:
class CDate
{
public:
CDate() {}
CDate(const CDate& date) {}
};
CDate function1()
{
CDate date();
return date;
|
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,...
|
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>...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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,...
| |