Can some one please tell me the problem with this code. I am reading each line using getline function and again using the same function for splitting the string for : delimiter.
string line,item;
ifstream myfile("hello.txt");
if(myfile.is_open()) {
string delim =":";
while(!myfile.eof()) {
vector<string> tokens;
getl...
I am using CLang but on using -ast-dump option I do not get the desired output
Code
ram@ram-desktop ~ $ cat a.cpp
class A{};
ram@ram-desktop ~ $ clang++ -cc1 -ast-dump a.cpp
typedef char *__builtin_va_list;
class A {
class A;
};
ram@ram-desktop ~ $
I thought I would be getting something like that mentioned by litb in th...
Please look at the following code:
#include <iostream>
using namespace std;
class A {
public:
A() {};
virtual void foo(double d) { cout << d << endl; }
virtual void foo(double d, int a) = 0;
};
class B : public A {
public:
B() {};
virtual void foo(double d, int a) { cout << d << endl << a << endl; }
...
I have different types, say A, B, C, that all inherit from some base class Base:
class Base { ... };
class A : public Base { ... };
class B : public Base { ... };
class C : public Base { ... };
I need a container, let's call it Master, that holds pointers to objects of types A, B and C. I want the Master container to provide an iterat...
I am currently researching using the TeamCity CI software for our comapanies CI automation needs but have had trouble finding information about using different build scripts with TeamCity. We have C++ projects that need to have build/test automation and we currently have licenses for TeamCity. I have looked into using scons for the build...
Hi everyone,
it occurred to me that it would be a good idea to manage a range of mapped memory (from glMapBuffer) with a std::vector.
// map data to ptr
T* dataPtr = (T*)glMapBuffer(this->target, access);
[... debug code ...]
// try to construct a std::vector from dataPtr
T* dataPtrLast = dataPtr + size;
mappedVector = new std::vecto...
Hi,
I'm building an hierarchy of objects that wrap primitive types, e.g integers, booleans, floats etc, as well as container types like vectors, maps and sets. I'm trying to (be able to) build an arbitrary hierarchy of objects, and be able to set/get their values with ease. This hierarchy will be passed to another class (not mentioned ...
Question: Not able to compile a C++ program with gcc compiler.
**oyscs1 /ms/user/a/agrajagr/test/macros 51$ cat info.C**
#include<iostream>
using std::cout;
using std::endl;
int main()
{
#ifdef __cplusplus
cout << "C++ compiler in use and version is " << __cplusplus << endl;
#endif
cout <<"Version is " << __STDC_VERSION__ << endl;
cout ...
Let have a type T and a struct having ONLY uniform elements of T type.
struct Foo {
T one,
T two,
T three
};
I'd like to access them in fallowing way:
struct Foo {
T one,
T two,
T three
T &operator [] (int i)
{
return *(T*)((size_t)this + i * cpp_offsetof(Foo, two));
}
};
where cpp_offse...
Hi @all,
I've got (probably) a simple question.
When do I have to declare a function used in a template?
The following code prints out (using gcc >=4.1):
init my A object
no init
Using gcc 4.0 the following code prints out:
init my A object
init my string object
#include <iostream>
#include <string>
template<typen...
Similar to the code written below exists in production. Could you people review it and tell me if such code works well all the time.
class Base
{
public:
virtual void process() = 0;
};
class ProductA : public Base
{
public:
void process()
{
// some implementation.
doSomething();
}
void ...
Is it possible to invoke cl.exe, the MSVC++ compiler, from inside a Visual Studio extension? I'm using VS2010 and not bothered about maintaining compatibility for 2008/2005. I've hunted through MSDN and had a poke through my DTE object, but not found anything of use. The documentation on what you can do with this stuff is kinda sparse.
...
I am trying to make an example of a toolkit work, but after typing make, I got the following error:
g++ -o taskintro taskintro.o `PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config orocos-ocl-gnulinux orocos-rtt-gnulinux --libs`
/usr/bin/ld: warning: libxerces-c-3.0.so, needed by /usr/local/lib/liborocos-rtt-gnulinux.so, not found (tr...
Hi,
Recently I was trying to add unit tests to an existing binary by creating a extra (DLLMain) entry point to an application that already has a main entry point (it is a console exe). The application seemed to compile correctly although I was unable to use it as a DLL from my python unit test framework, all attempts to use the exe as a...
why my program Time Limited Error?
because of the sort?
this is the question
link text
#include <cstdio>
#include <cstring>
using namespace std;
int map[22][44];
int book[22];
int total;
int sum;
int way[22];
int tails[22];
int tail;
void init()
{
memset(map,0,sizeof(map));
memset(book,0,sizeof(book));
sum =0;
memset(way,0,size...
Hello,
I want to define a macro which includes another header file like so:
#define MY_MACRO (text) #include "__FILE__##_inline.inl"
So that when the preprocessor parses file person.h, MY_MACRO(blahblah) expands to
#include "person.h.inline.inl"
any hints on how to do this ?
...
Hello all
i have simple app that i try to compile with VC express and using the :
microsoft platform sdk for windows server 2003 that contains mfc and atl
now i have this simple code :
CString strValue("test");
CString s = strValue.Trim();
LPCTSTR lpStr = (LPCTSTR)strValue.Trim()
that give me compilation error :
c:\dev\test.cpp(463) ...
I've tried OutputDebugString function and most of the time I get error like :
error C2664: 'OutputDebugStringA' : cannot convert parameter 1 from 'int' to 'LPCSTR'
Please suggest. Thanks.
...
I know that my destructors are called on normal unwind of stack and when exceptions are thrown, but not when exit() is called.
Are there any other cases where my destructors are not going to get called? What about signals such as SIGINT or SIGSEGV? I presume that for SIGSEGV, they are not called, but for SIGNINT they are, how do I kno...
While file to file effect chains are working fine, I'm having difficulty using the default audio device when compiling SoX from source. For example, if I run the example3 included in the source code (plays a sound file), I get the error
FAIL formats: no handler for given file type `alsa'
Assertion failed: out= sox_open_write("default",...