Monday, March 17, 2014

abstract class with virtual base class and non default constructor

Newsgroup: comp.lang.c++

Subject: abstract class with virtual base class and non default constructor

From: =?ISO-8859-1?Q?Marcel_M=FCller?= <news.5.maazl@...>

Date: Sat, 15 Mar 2014 18:26:54 +0100



Virtual base classes are always constructed by the most derived class.

So why need an abstract class a call to the constructor of it's virtual

base?



#include <stdio.h>



class V

{protected:

V(int i) { printf("V::V(%i)\n", i); }

};



class A : public virtual V

{protected:

A() : V(42) {} // <-- required to keep the compiler happy

virtual void PureFunc() = 0;

};



class D : public A

{public:

D(int i) : V(i) {}

protected:

void PureFunc() {}

};



int main()

{ D d(7);

}





From my understanding the constructor call V(42) could never be

executed, isn't it? A cannot be instantiated and any class inheriting

from A must initialize V::V(int) explicitly.





Marcel







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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Thursday, March 13, 2014

Escape sequence and character set problem

Newsgroup: comp.lang.c++

Subject: Re: Escape sequence and character set problem

From: Victor Bazarov <v.bazarov@...>

Date: Thu, 13 Mar 2014 11:44:16 -0400



On 3/13/2014 11:39 AM, nvangogh wrote:

> What values does this literal represent? What type does it have?

> "Who goes with F\145rgus?\012"

>

> This is from C++ Primer exercise 2.7 (p41 of 5th ed)

>

> I cannot figure this out.

>

> F is a suffix for float that only makes sense to me if numeric value

> came before it. But it comes before an escape sequence. What does \145

> mean? Taken as a whole can you explain how this line is put together and

> how I can interpret it?



Inside a string literal, letter F has no special meaning. It's just a

letter. However, \145 is an escape sequence designating a special

character (most likely) with the value of decimal 145, which is actually

not possible in a basic character set limited to -127..127. So, most

likely it's substituted with char(255-145), some negative value, but

will yield the same thing however. Look up in the extended ASCII table

to see what your computer is likely to output. Or just write a small

program to output that literal. If we designate that character with the

asterisk (like in Scrabble) and the newline (the second escape sequence

is the line feed character) with the tilda, the literal becomes "Who

goes with F*rgus?~"



What it will do when you output it depends on the device, though.



V

--

I do not respond to top-posted replies, please don't ask







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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Which constructor?

Newsgroup: comp.lang.c++

Subject: Which constructor?

From: ram@...

Date: 13 Mar 2014 12:38:42 GMT



I tried to modify the __gnu_debug string after #include

<debug/string> to get this information, but it did not work,

because I am having problems to print something from inside

of it using ?::std::cerr?.



So, maybe someone here can tell me: What constructor or

method or whatever of the string class is called in the

case of each of the following two object definitions?



#include <string> /* ::std::string */



int main()

{ ::std::string s{ "alpha" };

::std::string t ={ "beta" }; }









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

View all the progranning help forums at:

http://ift.tt/1dP9txN

TALK.ORIGINS CENSORS THE TRUTH

Newsgroup: comp.lang.c++

Subject: Re: TALK.ORIGINS CENSORS THE TRUTH

From: Catpain Merca <catpainmerca@...>

Date: Wed, 12 Mar 2014 22:28:55 +0000



On 12/03/2014 22:07, I THRINAXODON wrote:



I've never seen the talk.origins moderator censor the truth. I have

seen him ban some nym-shifting dipshits. I, on the other hand have

snipped your entire rant. Not really censorship, as your original post

still stands, but completely disregarded without being read by me owing

to the stupidity of your subject header.



Catpain Merca









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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Monday, March 10, 2014

Basic Types

Newsgroup: comp.lang.c++

Subject: Basic Types

From: nvangogh <nvangogh@...>

Date: Mon, 10 Mar 2014 17:42:10 +0000



Is it fair (and technically accurate) to say that the only differences

between int, long, long long and short is the number of bits that is

required to represent the type in the computer? Or is there additional

differences than size?







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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Which one(s) of the following std::vector's member functions has the possibility/authority to reduce a vector's capacity?

Newsgroup: comp.lang.c++

Subject: Which one(s) of the following std::vector's member functions has the possibility/authority to reduce a vector's capacity?

From: goodbyeera@...

Date: Sun, 9 Mar 2014 19:11:23 -0700 (PDT)



Which one(s) of the following std::vector's member functions has the possibility/authority to reduce a vector's capacity?



I have 5 member functions in question:

template <class T, class Allocator = allocator<T> >

class vector {

public:

vector<T,Allocator>& operator=(const vector<T,Allocator>& x);

vector<T,Allocator>& operator=(vector<T,Allocator>&& x);

vector& operator=(initializer_list<T>);

void assign(initializer_list<T>);

void clear() noexcept;

};



Notes:

- For assignments: Unlike vector::swap() which explicitly specifies exchanging both contents and capacity, I can't find reliable answers for the various forms of assignments.

- For std::assign(), there are 2 other overloads:

template <class InputIterator> void assign(InputIterator first, InputIterator last);

void assign(size_type n, const T& u);

And they are both explicitly defined in terms of calls to erase() and insert(), so it's guaranteed with no reduce in capacity. But for the overload taking an initializer_list as the argument, I can't find a reliable answer.

- For std::clear(), in C++03, it's explicitly defined in terms of erase(begin(),end()), so it's guaranteed with no reduce in capacity. I can't find equivalent definition in C++11 anymore.



Relevant excerpts from the standard are highly appreciated.



Thanks,

Goodbyeera







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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Saturday, March 8, 2014

Speech Recognition for Neural diseases Persons

Newsgroup: comp.lang.c++

Subject: Speech Recognition for Neural diseases Persons

From: almostcash@...

Date: Sat, 8 Mar 2014 05:08:36 -0800 (PST)



I am making a speech recognition program in C++ for for neural disease person.



the program should take input from the mic and convert the speech into text.



i have tried the microsoft sapi and other normal speech reconition api, however it just doesnt work in my case.



the persons i am talking about they cant prounounce the words properly. they can only speak few words clearly.



so i need an api or something which could use the limited vocablary option in order to convert speech into text.



thats the only way i think to make this work to be done properly.







suggestion needed







thanks









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

View all the progranning help forums at:

http://ift.tt/1dP9txN

Tuesday, March 4, 2014

Brand new C++ container released

Newsgroup: comp.lang.c++

Subject: Brand new C++ container released

From: Mr Flibble <flibbleREMOVE_THIS_AND_THIS@...>

Date: Wed, 05 Mar 2014 00:41:37 +0000



A brand new C++ container called "segmented_array" has been released

which offers fast insert/erase anywhere in a controlled sequence:



http://ift.tt/1f4Vl3V



It performs better than its closest competition (avl_array).



Example timings:



std::vector random erase: 17.1273 seconds

std::deque random erase: 17.6862 seconds

std::list random erase: 24.1854 seconds

mkr::avl_array random erase: 0.1263 seconds

neolib::segmented_array (1) random erase: 0.3113 seconds

neolib::segmented_array (2) random erase: 0.1370 seconds

neolib::segmented_array (3) random erase: 0.1206 seconds

neolib::segmented_array (4) random erase: 0.1198 seconds

std::vector random insert: 73.9902 seconds

std::deque random insert: 25.0955 seconds

std::list random insert: 52.6922 seconds

mkr::avl_array random insert: 0.1513 seconds

neolib::segmented_array (1) random insert: 0.2608 seconds

neolib::segmented_array (2) random insert: 0.1170 seconds

neolib::segmented_array (3) random insert: 0.1158 seconds

neolib::segmented_array (4) random insert: 0.1636 seconds

std::vector random access: 0.0055 seconds

std::deque random access: 0.0095 seconds

std::list random access: 60.9293 seconds

mkr::avl_array random access: 0.0850 seconds

neolib::segmented_array (1) random access: 0.1100 seconds

neolib::segmented_array (2) random access: 0.0470 seconds

neolib::segmented_array (3) random access: 0.0352 seconds

neolib::segmented_array (4) random access: 0.0278 seconds

std::vector sequential access: 0.0019 seconds

std::deque sequential access: 0.0026 seconds

std::list sequential access: 0.0133 seconds

mkr::avl_array sequential access: 0.0138 seconds

neolib::segmented_array (1) sequential access: 0.0180 seconds

neolib::segmented_array (2) sequential access: 0.0032 seconds

neolib::segmented_array (3) sequential access: 0.0028 seconds

neolib::segmented_array (4) sequential access: 0.0027 seconds

std::vector sort: 0.0242 seconds

std::deque sort: 0.0491 seconds

std::list sort: 0.0980 seconds

mkr::avl_array sort: 0.7306 seconds

neolib::segmented_array (1) sort: 0.6190 seconds

neolib::segmented_array (2) sort: 0.0579 seconds

neolib::segmented_array (3) sort: 0.0494 seconds

neolib::segmented_array (4) sort: 0.0452 seconds



/Flibble







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

View all the progranning help forums at:

http://ift.tt/1dP9txN