How to understand the following c++ code ?
inpfile>>ch; if(ch<16) outfile<<"0×0"<<std::hex<<setprecision(2)<<(int)ch<<" "; what does std::hex<<setprecision(2) mean? ...
inpfile>>ch; if(ch<16) outfile<<"0×0"<<std::hex<<setprecision(2)<<(int)ch<<" "; what does std::hex<<setprecision(2) mean? ...
I know a simple int vector have O(1) random access time, since it is easy to compute the position of the xth element, given all elements have the same size. Now whats up with a string vector? Since the string lengths vary, it can't have O(1) random access time, can it? If it can, what is the logic behind it? Thanks. Update: The answ...
I am using SWIG to access C++ code from Java. What is the easiest way to expose a std::string parameter passed by non-const reference? I have primitives passed by reference exposed as Java arrays, thanks to typemaps.i, and const std::string&s exposed as java.lang.String, thanks to std_string.i. But a non-const std::string& is exposed a...
hello, I want to send data and a capability description to a remote site. Upon receiving the data at the remote site, I want to look at the description and create an object (via a factory method ) doing exactly what I want when I invoke exec on it. Examples: 1) send [3, (add 5) ] => receive(obj); obj->exec() -> 8 2) send [3, (add -...
I'm trying to split a string using the method found in this thread, but I'm trying to adapt it to a wstring. However, I have stumbled upon a weird error. Check the code: #include <iostream> #include <sstream> #include <string> #include <vector> #include <algorithm> #include <iterator> using namespace std; int main(void) { wstring ...
Hello, This is a bit of a daft question, but out of curiousity would it be possibly to split a string on comma, perform a function on the string and then rejoin it on comma in one statement with C++? This is what I have so far: string dostuff(const string& a) { return string("Foo"); } int main() { string s("a,b,c,d,e,f"); vect...
Is there ever such a pattern of dependancies that it is impossible to keep everything in header files only? What if we enforced a rule of one class per header only? For the purposes of this question, let's ignore static things :) ...
Hi, I have a question. Can anyone tell me why someone would declare parameter r like that ? Whats the difference between Record& r and Record(&r) ? QDataStream& operator>>(QDataStream &s, Record(&r)) { } Thanks :) ...
I have a class (JSObject) that implements the IDispatch interface. The class is exposed to JavaScript running in my hosted web browser control (IWebBrowser2). See more here about how this works: http://stackoverflow.com/questions/3747414/calling-c-function-from-javascript-script-running-in-a-web-browser-control I can call in to JSObjec...
I am trying to understand the following example, that is similar (but not equal) to the one posted earlier on the SO http://stackoverflow.com/questions/2120725/help-understanding-boostbind-placeholder-arguments : #include <boost/bind.hpp> #include <functional> struct X { int value; }; int main() { X a = { 1 }; X b = {...
Hello, if I wanted to return "this" from a class member function as reference would this piece of code be correct ? Record return *this; } Shouldn't i just use "return this" ? Thanks for help :) ...
The issue is that the further the mouse click is from the top left origin (0,0) the greater the height inaccuracy when the vertex is plotted. Any ideas? int WindowWidth = 19; int WindowHeight = 13; int mouseClickCount = 0; int rectPlotted; GLint x1; GLint y1; GLint x2; GLint y2; //Declare our functions with prototypes: void display(voi...
Hi all, Any recommendations out there for Windows application tuning resources (books web sites etc.)? I have a C++ console application that needs to feed a hardware device with a considerable amount of data at a fairly high rate. (buffer is 32K in size and gets consumed at ~800k bytes per second) It will stream data without under run...
I have started an C++ SFML project for linux. I was wondering where the .so's should go. Should they go inside the project folder so a user can simply run the program after they get it? Or should the user have the SFML library installed on there linux machine before they run my program? ...
How much space is allocated by boost compressed_matrix? Is it true that it only allocates space for non-zero elements? If this is true, I don't understand why the following code gives bad_alloc error. namespace bubla = boost::numeric::ublas; typedef double value_type; typedef bubla::compressed_matrix<value_type> SparseMatrix; unsign...
Hi, I'm using SWIG to wrap C++ code to Python code. I'm trying to wrap a vector of vectors. The method is: std::vector<std::vector<MyClass*>*> GetMyClassVectorOfVectors(); I'm able to wrap the first vector without adding lines to the file "MyAplication.i": The method is std::vector<MyClass*> GetMyClassVector(); And this is working...
Hi, I have to use an external library, but am getting a "multiple definition error" from following template function and its explicit specialization, if it gets called with a std::string. template <typename T> void foo(T& value); template <> void foo(std::string& value); even if I change the 2nd function to void foo(std::string& va...
I'm using an embedded compiler for the TI TMS320F28335, so I'm not sure if this is a general C++ problem (don't have a C++ compiler running on hand) or just my compiler. Putting the following code snippet in my code gives me a compile error: "build\main.cpp", line 61: error #317: the object has cv-qualifiers that are not compatible wit...
I am wrapping a native C++ library for consumption by the CLR. However, I'm running into a strange... problem? The native library's headers look like so: namespace Foo { class Bar { public: Bar(); //etc... }; } So, to consume this class, I have my own class definition: #include "Foo/Bar.h" namespace Fo...
I keep encountering this "Debug assertions failed!" error when I run my program in debug mode. I tried looking this error up on the visual C++ website but the explanations are too advanced for me and they don't have any resemblance to what my best guess as to the problem is. I have went through my code and narrowed down the point at whi...