Boost bind with asio::placeholders::error
...
I have webpage I downloaded with C++ to a string, and it is basically a massive <li> list of links. I need to find the last 2 elements of the list. Can anyone help me on how to do this? ...
Lets say I have an abstract class Cat that has a few concrete subclasses Wildcat, Housecat, etc. I want my array to be able to store pointers to a type of cat without knowing which kind it really is. When I try to dynamically allocate an array of Cat, it doesn't seem to be working. Please help? Cat* catArray = new Cat[200]; ...
I'm interested in the nuts and boltw of C++ and I wondered what actually changes when an object is instantiated. I'm particularly interested if the functions are then added to memory, if they are there from runtime or if they are never stored in memory at all. If anyone could direct me to a good site on some of the core bolts of C and ...
I have a program written in c++ that I want to profile, and I want to avoid restarting it when I start and stop profiling. Ideally I would be profiling both CPU usage and memory allocation. Is there any tool that will allow me to do this? I'm running on Linux. ...
For a class assignment, I have to use two stacks in C++ to make an equation to be converted to its left to right equivalent: 2+4*(3+4*8) --> 35*4+2 --> 142 Here is the main code: #include <iostream> #include <cstring> #include "ctStack.h" using namespace std; int main (int argc, char * const argv[]) { string expression = "2+4*2"; ...
I am trying to write a function that takes a pointer argument, modifies what the pointer points to, and then returns the destination of the pointer as a reference. I am getting the following error: cannot convert int*** to int* in return Code: #include <iostream> using namespace std; int* increment(int** i) { i++; return ...
I use C++ to implement a thread class. My code shows in the following. I have a problem about how to access thread data. In the class Thread, I create a thread use pthread_create() function. then it calls EntryPoint() function to start thread created. In the Run function, I want to access the mask variable, it always shows segment fault...
I'd like to minimize synchronization and write lock-free code when possible in a project of mine. When absolutely necessary I'd love to substitute light-weight spinlocks built from atomic operations for pthread and win32 mutex locks. My understanding is that these are system calls underneath and could cause a context switch (which may be...
I am learning C++. Just curious, can only static and constant varibles be assigned a value from within the class declaration? Is this mainly why when you assign values to normal members, they have a special way doing it void myClass::Init() : member1(0), member2(1) { } ...
Having trouble creating my swap chain. I receive the following error. DX3dApp.obj : error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "public: bool __thiscall DX3dApp::InitDirect3D(void)" (?InitDirect3D@DX3dApp@@QAE_NXZ) Below is the code ive done so far. #include "DX3dApp.h" bool ...
Here is some code copied from Thinking in C++ Vol1 Chapter 10. #include <iostream> using namespace std; int x = 100; class WithStatic { static int x; static int y; public: void print() const { cout << "WithStatic::x = " << x << endl; cout << "WithStatic::y = " ...
Hi everyone, After reading the answer to this question, I learned that SFINAE can be used to choose between two functions based on whether the class has a certain member function. It's the equivalent of the following, just that each branch in the if statement is split into an overloaded function: template<typename T> void Func(T& arg)...
I use c++ to implement a thread class. The code is in the following. I initialize two objects, wish it will start two threads (I use pthread_self() to look the thread Id). But the result shows that there is only one thread beside the main thread. I am a bit confused... class Thread { public: int mask; pthread_t thread; Thread( in...
I am using Named Capture Groups with Boost Regex / Xpressive. I would like to iterate over all submatches, and get both the value and KEY of each submatch (i.e. what["type"]). sregex pattern = sregex::compile( "(?P<type>href|src)=\"(?P<url>[^\"]+)\"" ); sregex_iterator cur( web_buffer.begin(), web_buffer.end(), pattern ); sregex_i...
If I put this code in a .cpp file and run it, it runs just fine: #include <iostream> #include <vector> #include <string> using namespace std; typedef vector<int> row; typedef vector<row> myMatrix; void main() { //cout << endl << "test" << endl; myMatrix mat(2,2); mat[0][1] = 2; cout << endl << mat[0][1] << endl; } ...
Why would you need to overload the [] operator? I have never come across a practical scenario where this was necessary. Can somebody tell me a practical use case for this. ...
I am just learning how to handle errors in my C++ code. I wrote this example that looks for a text file called some file, and if its not found will throw an exception. #include <iostream> #include <fstream> using namespace std; int main() { int array[90]; try { ifstream file; file.open("somefile.txt"); if(!file.good()) th...
dear experts, I have a vector t_vec that stores references to instances of class Too. The code is shown below. In the main , I have a vector t_vec_2 which has the same memory address as B::t_vec. But when I try to access t_vec_2[0].val1 it gives error val1 not declared. Could you please point out what is wrong? Also, if you know of ...
The following source file will not compile with the MSVC compiler (v15.00.30729.01): /* stest.c */ #ifdef __cplusplus extern "C" { #endif struct Test; /* NB: This may be extern when imported by another module. */ struct Test make_Test(int x); struct Test { int x; }; struct Test make_Test(int x) { struct Test r; r.x = x; ...