473,321 Members | 1,748 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,321 software developers and data experts.

c++ primer statement about vectors containing vectors

C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>something;

The concern is that >will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two characters.

Is the above code a real problem or not?

Thanks,

Paul Epstein
Mar 26 '08 #1
3 1450
pa**********@att.net wrote:
C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>something;

The concern is that >will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two characters.

Is the above code a real problem or not?
Yes, it is. Your particular compiler may add that feature as an
extension, and it's also slated for C++0x, but it is not standard
compliant code.
Mar 26 '08 #2
On Mar 26, 4:34 am, pauldepst...@att.net wrote:
C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>something;

The concern is that >will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two characters.

Is the above code a real problem or not?

Thanks,

Paul Epstein
Can you post the chapter and page where did you find that? (among with
the edition of the book)

I read that book and I remember they specified that you *have* to
leave a white space between the two '>'. Maybe not in every
occurrence, but they did it at least when they wrote
std::vector<std::vector<double for the first time.
Mar 26 '08 #3
pa**********@att.net wrote:
C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>something;

The concern is that >will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two characters.

Is the above code a real problem or not?
As stated elsethread, it's illegal without the whitespace according to
the current standard, but that looks like it will change for the next
standard. Here's an interesting relevant article from the standards
committee:
http://www.open-std.org/JTC1/SC22/WG...005/n1757.html

--
SM
rot13 for email
Mar 26 '08 #4

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

Similar topics

5
by: Pratyush | last post by:
Hi, Suppose there is a vector of objects of class A, i.e., std::vector<A> vec_A(N); The class A satisifies all the STL vector requirements. Now I wish to add some attributes for each of the...
4
by: Dr. J.K. Becker | last post by:
Hi all, I have vectors that holds pointers to other vectors, like so: vector<whatever> x; vector<whatever*> z; z=&x; Now I add something to x
5
by: roberts.noah | last post by:
It is my understanding that if you contain vectors or maps you don't need to create copy constructors because the default calls that constructor. It is my understanding that if you use these types...
0
by: acosgaya | last post by:
hi, I am working in this problem, where I have a set of N d-dimensional points, e.g. (4,5,6,8) (2,0,4,6), are 4-d points, which I have stored in a vector of vectors. I am trying to partition...
1
by: pallav | last post by:
I am writing a logic simulator for boolean circuits. I have a textfile which will contain vectors like this abc 001 100 111 ... I want to be able to bit pack these vectors to get a = 110, b...
11
by: arnuld | last post by:
i have solved the problem but it is quite length. as usual, i wanted some coding-standards or good-design opinions: /* C++ Primer 4/e * chapter 3 - Library Types * exercise 3.13 *...
8
by: arnuld | last post by:
i have solved it. any suggestions for improving the code: /* C++ Primer - 4/e * chapter 3 * exercise 3.14 * STATEMENT read some text into a vector,storing each word as an elelment in the...
33
by: arnuld | last post by:
it works fine. i am posting it to know your views (please remember, i am at chapter 6, so i have not encountered stuf like Functions): /* C++ Primer - 4/e * * exercise 6.20 * STATEMENT * ...
20
by: arnuld | last post by:
I get an error, can't find what is the problem: /* C++ Primer - 4/e * * Chapter 8, exercise 8.3 * STATEMENT * write a function that takes and returns an istream&. the function should read...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.