Monday, December 2, 2013

How am I supposed to define this namespace variable?

Newsgroup: comp.lang.c++

Subject: How am I supposed to define this namespace variable?

From: "A" <a@...>

Date: Mon, 2 Dec 2013 18:57:01 +0100



Header file:



namespace MyNameSpace

{

extern const wchar_t CharArr[];

extern const int IntArr[];

}



Src file:



const wchar_t MyNameSpace::CharArr[] = "abc";

const int MyNameSpace::IntArr[5] = { 1,2,3,4,5};





-- the problem - when I access these variables I get a runtime error as if I

was trying to access undefined part of memory. But I don't understand why...

variable should be defined and debugger sees them.











via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?140882-How-am-I-supposed-to-define-this-namespace-variable&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Thursday, November 28, 2013

vector

Newsgroup: comp.lang.c++

Subject: vector

From: Rosario1903 <Rosario@...>

Date: Thu, 28 Nov 2013 10:59:07 +0100





why the below goes to seg fault?



#include <iostream>

#include <vector>

using namespace std;



void f(vector<unsigned>& v)

{v[3]=4; v[4]=9;}





int main(void)

{vector <unsigned> mv;



mv[0]=1; mv[1]=2;

f(mv);

cout<<"mv[0]="<<mv[0]<<", mv[1]="<<mv[1]<<"\n";

cout<<"mv[3]="<<mv[3]<<", mv[4]="<<mv[4]<<" mv[5]="<<mv[5]<<"\n";



return 0;

}









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?138316-vector&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Wednesday, November 27, 2013

Comparing C++ Compilers on Windows

Newsgroup: comp.lang.c++

Subject: Comparing C++ Compilers on Windows

From: Lynn McGuire <lmc@...>

Date: Wed, 27 Nov 2013 12:12:59 -0600



Comparing C++ Compilers on Windows:

http://slashdot.org/topic/cloud/speed-test-2-comparing-c-compilers-on-windows/



"In all cases I?m using the 64-bit versions of the

compilers. But let?s be clear about something: When

I say 64-bit compiler, I?m talking about the generated

code. The compiler itself may or may not be a 64-bit

application."



Bummer, no comparison tables or charts.



Lynn







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?137835-Comparing-C-Compilers-on-Windows&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Sunday, November 24, 2013

Can the heap (free store) be corrupted by passing a vector by value to a function?

Newsgroup: comp.lang.c++

Subject: Can the heap (free store) be corrupted by passing a vector by value to a function?

From: bobl0456@...

Date: Sun, 24 Nov 2013 11:23:40 -0800 (PST)



If you mistakenly passed a vector by value to a function and the function modified the vector, could such action cause the heap to become corrupted?



It would seem to me that the answer to my question is yes.



Thanks in advance,



Bob







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?135204-Can-the-heap-(free-store)-be-corrupted-by-passing-a-vector-by-value-to-a-function&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Replacement for _getch()?

Newsgroup: comp.lang.c++

Subject: Replacement for _getch()?

From: Geoff <geoff@...>

Date: Fri, 22 Nov 2013 08:25:07 -0800



The Microsoft _getch() function gets a character from the console

without echo. It does not require a carriage return. It returns the

character (int) read and does not have an error return. This makes it

very handy for console applications that want to wait for a single

keystroke from the user or for password inputs where echo is

problematic.



Is there a replacement for this non-standard function in C++?



std::cin.ignore() and std::cin.get() fail as direct replacements since

they require the enter key and not just any key be pressed.



Solutions involving ncurses or unistd.h are unsatisfactory for the

same reason conio.h is unsatisfactory.







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?133989-Replacement-for-_getch()&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Thursday, November 21, 2013

How to represent a SPACE and a BLANK in HEX in C++?

Newsgroup: comp.lang.c++

Subject: How to represent a SPACE and a BLANK in HEX in C++?

From: ssmile03@...

Date: Wed, 20 Nov 2013 17:04:42 -0800 (PST)



How to represent a SPACE and a BLANK in HEX in C++?



I am using '0x20' for SPACE and '0x00' for BLANK in hex in C++. Am I correct?



Thanks







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?132903-How-to-represent-a-SPACE-and-a-BLANK-in-HEX-in-C&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

Wednesday, November 20, 2013

When to prefer "for_each"?

Newsgroup: comp.lang.c++

Subject: When to prefer "for_each"?

From: ram@...

Date: 15 Nov 2013 16:54:34 GMT



In the web, I found a text claiming that



for( ...::iterator i = ....begin(); ... )...



was ?old C++?, while



for_each( ..., [&]... )...



was ?new C++?. So, in the general case, is there any advantage

in using ?for_each? instead of ?for? for such loops?









via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?129143-When-to-prefer-for_each&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums