Sunday, May 11, 2014

simple class

Newsgroup: comp.lang.c++

Subject: simple class

From: nvangogh <nvangogh@...>

Date: Fri, 09 May 2014 14:53:51 +0100



Hi,

I am reading c++ primer.



Exercise 7.4:

Write a class named person that represents the name and address of a

person. Use a string to hold each of these elements. Subsequent

exercises will incrementally add features to this class.



Exercise 7.5:

Provide operations in your person class to return the name and address.

Should these functions be const? Explain your choice.



So I have completed exercise 7.5 in this way:



// a class named person with operations



#include <string>



class Person

{

std::string name() const { return first_name;}

std::string addr() const { return address;}



// data members

std::string first_name;

std::string address;

};



Is this correct?









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1l7kTAL

View all the progranning help forums at:

http://ift.tt/1dP9txN

Thursday, May 8, 2014

Does C++ Primer offer non-trivial example programs? If not, please suggest a book that does.

Newsgroup: comp.lang.c++

Subject: Does C++ Primer offer non-trivial example programs? If not, please suggest a book that does.

From: Aditya Raj Bhatt <adityarajbhatt@...>

Date: Thu, 8 May 2014 05:09:21 -0700 (PDT)



I am seeing recommendations for C++ Primer everywhere (on the C++-faq lite, the stackoverflow list of C++ books) and other places. Now, I bought it and went through the index, but I was dismayed to find only C++ _features_ listed, and no sign of any non-trivial examples.



I have gone through Object Oriented Programming in _Turbo_ C++ by Robert Lafore. While severely outdated, it taught me many useful applications of the features in C++ (A card game, a horse simulation, fractals, a small adventure game) etc. I was wondering if C++ primer offers examples like this. I find it gets very dull if they just say something like, "you can pass a reference parameter using &. Eg.



void Examplefunction (int &x, int &y) {

x=5; y=6;

}



int main() {

int x,y; Examplefunction(x,y);

return 0;

}



"





Stuff like this is very boring to me, with no possible application. I mean, I am not a very creative person, and unless the application of a concept is shown to me explicitly through some useful example, I have a hard time remembering it. So can someone tell me if C++ Primer offers things like this (please mention what specific example it is). And if not, please recommend a book that is heavy on both explanation and big examples (at least, big from the point of a beginner).



Thank you and sorry for being overly verbose. This is my first post on this group.







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1obopQE

View all the progranning help forums at:

http://ift.tt/1dP9txN

Thursday, May 1, 2014

ostream Problem

Newsgroup: comp.lang.c++

Subject: ostream Problem

From: mrc2323@...

Date: Thu, 1 May 2014 13:46:07 -0700



I am trying to combine std::left and std::setw() as a single

function. The following code ignores the "left" manipulator. What am I

doing wrong? TIA



struct leftsetw // combined functions (left/width)

{

leftsetw(int w) : width(w) {}

int width;

};

ostream &operator<<(ostream &o, const leftsetw &a)

{

o.left, o.width(a.width);

return o;

}



ostringstream oss;

oss.str(""); oss << "Test " << leftsetw(12) << 42;



---

This email is free from viruses and malware because avast! Antivirus protection is active.

http://www.avast.com









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1rUi3oo

View all the progranning help forums at:

http://ift.tt/1dP9txN

Wednesday, April 30, 2014

Onslaught

Newsgroup: comp.lang.c++

Subject: Re: Onslaught

From: Chris Hinsley <chris.hinsley@...>

Date: Wed, 30 Apr 2014 14:33:39 +0100



On 2013-06-07 17:42:45 +0000, Chris Hinsley said:



Mmm, Has anyone even had a look ? I do have an improved version of the

engine that is mush more c++ if anyone is interested. But this code is

old enough not to drag into the future.



Regards



Chris









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1nJ4w3h

View all the progranning help forums at:

http://ift.tt/1dP9txN

Tuesday, April 29, 2014

=?ISO-8859-1?Q?=A73=2E5=2F6_in_the_C=2B=2B11_Standard?=

Newsgroup: comp.lang.c++

Subject: =?ISO-8859-1?Q?=A73=2E5=2F6_in_the_C=2B=2B11_Standard?=

From: Ayrosa <jabelloc@...>

Date: Tue, 29 Apr 2014 12:44:18 -0700 (PDT)



§3.5/6



The name of a function declared in block scope and the name of a variable declared by a block scope extern declaration have linkage. If there is a visible declaration of an entity with linkage having the same name and

type, ignoring entities declared outside the innermost enclosing namespace scope, the block scope declaration declares that same entity and receives the linkage of the previous declaration. If there is more than one such matching entity, the program is ill-formed. Otherwise, if no matching entity is found, the block scope entity receives external linkage.[ Example:



static void f();

static int i = 0; // #1

void g() {

extern void f(); // internal linkage

int i; // #2 i has no linkage

{

extern void f(); // internal linkage

extern int i; // #3 external linkage

}

}



There are three objects named i in this program. The object with internal linkage introduced by the declaration in global scope (line #1 ), the object with automatic storage duration and no linkage introduced by the declaration on line #2, and the object with static storage duration and external linkage introduced by the declaration on line #3. --end example ]



Consider the i object in line #3. Why does it have static storage duration and external linkage?







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1m8TcOw

View all the progranning help forums at:

http://ift.tt/1dP9txN

new 2014 women's spiked pointed toe genuine leather red bottom high-heels shoes,designer brand women 12cm pumps wedding shoes

Newsgroup: comp.lang.c++

Subject: new 2014 women's spiked pointed toe genuine leather red bottom high-heels shoes,designer brand women 12cm pumps wedding shoes

From: toptradea@...

Date: Tue, 29 Apr 2014 08:32:57 -0700 (PDT)



new 2014 women's spiked pointed toe genuine leather red bottom high-heels shoes,designer brand women 12cm pumps wedding shoes



http://ift.tt/1mWL5kV



top fashion store 2014(http://ift.tt/1mWL3cV)

Men Sneakers(http://ift.tt/1m80D8v)

Men Flats(http://ift.tt/1mWL14H)

Men Sandals(http://ift.tt/1m80F0i)

Women Sneakers(http://ift.tt/1mWL3d1)

Women Pumps(http://ift.tt/1m80FgA)

Women Sandals(http://ift.tt/1mWL14N)

Women Flats(http://ift.tt/1m80G44)

Women Boots(http://ift.tt/1m80FgG)

Women Clothing(http://ift.tt/1m80G47)

Women Dresses(http://ift.tt/1mWL3JR)

Women Bandage Dress(http://ift.tt/1m80G4g)

Women Bandage Jumpsuit(http://ift.tt/1mWL1lf)

Children Clothing Boys Girls Sets Shoes(http://ift.tt/1m80G4i)

Brazilian virgin hair (http://ift.tt/1mWL3K3)

Malaysian Virgin Hair (http://ift.tt/1mWL1ll)

Peruvian Virgin Hair (http://ift.tt/1mWL1BC)

Indian Virgin Hair (http://ift.tt/1mWL1BI)

Mongolian Virgin Hair (http://ift.tt/1m80Fx7)







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1mWL2Wm

View all the progranning help forums at:

http://ift.tt/1dP9txN

Hot sale new summer 2014 women's causal princess dress,brand designer round neck high waist sleeveless dresses Free shipping S M L Discount Price:US $14.42

Newsgroup: comp.lang.c++

Subject: Hot sale new summer 2014 women's causal princess dress,brand designer round neck high waist sleeveless dresses Free shipping S M L Discount Price:US $14.42

From: toptradea@...

Date: Tue, 29 Apr 2014 08:23:30 -0700 (PDT)



Hot sale new summer 2014 women's causal princess dress,brand designer round neck high waist sleeveless dresses Free shipping SML

S M L Discount Price:US $14.42

http://ift.tt/1mWL4xp



top fashion store 2014(http://ift.tt/1mWL3cV)

Men Sneakers(http://ift.tt/1m80D8v)

Men Flats(http://ift.tt/1mWL14H)

Men Sandals(http://ift.tt/1m80F0i)

Women Sneakers(http://ift.tt/1mWL3d1)

Women Pumps(http://ift.tt/1m80FgA)

Women Sandals(http://ift.tt/1mWL14N)

Women Flats(http://ift.tt/1m80G44)

Women Boots(http://ift.tt/1m80FgG)

Women Clothing(http://ift.tt/1m80G47)

Women Dresses(http://ift.tt/1mWL3JR)

Women Bandage Dress(http://ift.tt/1m80G4g)

Women Bandage Jumpsuit(http://ift.tt/1mWL1lf)

Children Clothing Boys Girls Sets Shoes(http://ift.tt/1m80G4i)

Brazilian virgin hair (http://ift.tt/1mWL3K3)

Malaysian Virgin Hair (http://ift.tt/1mWL1ll)

Peruvian Virgin Hair (http://ift.tt/1mWL1BC)

Indian Virgin Hair (http://ift.tt/1mWL1BI)

Mongolian Virgin Hair (http://ift.tt/1m80Fx7)







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1mWL28M

View all the progranning help forums at:

http://ift.tt/1dP9txN