I've started learning C++ and am working through some exercises in the C++ Primer Plus book.
In chapter 5 one of the exercises is:
Write a program that uses an array of
char and a loop to read one word at a
time until the word done is entered.
The program should then report the
number of words entered (not counting
done)....
hello
i am using this code to replace the while space but it never replaces all the white space can u please tell me where i am wrong
#include <iostream>
#include <string>
#include <boost/regex.hpp>
#include<boost/algorithm/string.hpp>
#include<boost/algorithm/string/replace.hpp>
using namespace std;
int main(void)
{
string...
I want to be able to set the individual pixels of the back buffer in my program in an efficient way. This is what I call in my rendering function:
void render_frame(void)
{
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
d3ddev->BeginScene();
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO,...
While reviewing rather old code I found some strange design decision:
// irrelevant stuff removed
class Class {
public:
int GetStage() const { return stage; }
void SetStage( int value ) { stage = value; }
private:
int stage;
};
void ProgressStage( Class* object )
{
int stage = object->GetStage();
assert( stage < MaxSta...
Hello, I have to store a list of different boost::function objects. To provide this I'm using boost::any. I have a few functions which takes different functions signatures, pack them into any and then insert into special map with given type. Here is the code:
enum TypeEnumerator
{
e_int,
e_float,
e_double
};
typedef map< st...
Hi,
I have developed one server pgm for multicasting in C++, when i register the address and after that when i set the socket option using setsockopt it returns me -1
If this option is not supported in setsockopt then how i can go for multicasting in C++
My code is below :
#include"winsock.h"
#include<iostream>
#include<conio.h>
usi...
Hello fellow SOers,
I'm asking this mainly out of curiousity. I am not really a C(++) Coder but to widen my horizon I try to dive in other areas every now and then. When doing this with C++ and some Winapi things, I encountered this guy:
#if defined(MIDL_PASS)
typedef struct _LARGE_INTEGER {
#else // MIDL_PASS
typedef union _LARGE_INTE...
I have created structure :
struct buffer
{
string ProjectName ;
string ProjectID ;
}
buffer buf;
buf.ProjectID = "212";
buf.ProjectName = "MyProj";
Now to send this structure using sendto method , I am typecasting the strucure and sending it back as below:
char *sendbuf = (char*)&buf;
sentbytes = sendto(sock,sendbuf,strlen(s...
Motivated by the discussion
The grammar for C++ classes is defined as
class-key identifier *[opt]* base-clause *[opt]* (Italics are mine)
This to me means that the class name is option and we can have unnamed classes in C++.
So, is the following well-formed?
struct X{
struct{
int x;
int y;
};
};
int main(){}
...
This is my little big question about containers, in particular, arrays.
I am writing a physics code that mainly manipulates a big (> 1 000 000) set of "particles" (with 6 double coordinates each). I am looking for the best way (in term of performance) to implement a class that will contain a container for these data and that will provid...
Hi,
I made a prototype of a project with PyQt and made it work there, now I'm trying to convert it to C++ and am having some problems.
If I don't put the Q_OBJECT macro in, it compiles and works, but if I comment it out, I get the following errors:
Undefined symbols:
"vtable for MapView", referenced from:
MapView::~MapView()in...
Hi all,
This question is about a C++ library for Windows and we use Visual C++ as our compiler.
We enable exception handling compiler option in our library. We also use throw/catch in a few places.
One of our customers says that they disable exception handling option in their application. Now the question is, whether they would exper...
Possible Duplicate:
What is the difference between using a struct with two fields and a pair?
Dear all,
I have a little question about pairs and struct. Is there any advantage to use a std::pair instead of a struct with two cells ?
I have used pairs for a while but the main problem is readability :
If you want to represent fo...
As per req i have to create stl queue on heap
i have created stl queue on heap in constructor of my class as per below code
queue<int> *myqueue;
myqueue=new queue<int>();
Now in destructor i want to destroy it:
so i have written code
while(!myqueue->empty())
{
myqueue->pop();
}
please tell me is it right way to destroy it or th...
I have two classes A and B, and an implicit conversion operator exists to go from one to the other, so that:
A a;
B b;
b = a; // Works
Is there a standard way to convert a std::list<A> to a std::list<B> ? (Or even from std::vector<A> to a std::list<B>).
I know I can iterate trough to the list and build the second list item by item, b...
Possible Duplicate:
strange output in comparision of float with float literal
#include<stdio.h>
int main()
{
float me = 1.7;
if(me==1.7)
printf("C");
else
printf("C++");
}
Output: C++
Now the reason for this behaviour is said that many floating point numbers cant be represented with absolute precision in binary.
My...
In my project I need a dedicated server that dispatches the streams over to multiple clients.
More specificly, I've a callback function that gets called to gather the stream data, but no idea how to stream it over to other applications.
What's the best way to get started on this ?
...
This is linked to my previous post
Wher I created a Struct :
struct buffer
{
char ProjectName[20];
char ProjectID[20];
};
Now while I am trying to assign values to it:
buffer buf;
buf.ProjectID = "3174";
buf.ProjectName = "NDS";
I am getting this error:
error C2440: '=' : cannot convert from 'char [5]' to 'char [20]'
...
How would I take control of the console of a batch file, and load it into my c++ application?
...
virtual and inline are function specifier.
They can appear before function only.{as per my understanding}.
Then,In following code what is virtual?
class Base
{
//
};
class Derived :virtual public Base
{
};
...