We are developing a real-time system that will be performing sin/cos calculations during a time critical period of operation. We're considering using a lookup table to help with performance, and I'm trying to benchmark the benefit/cost of implementing a table. Unfortunately we don't yet know what degree of accuracy we will need, but pro...
Is it possible to return a standard container from a function without making a copy?
Example code:
std::vector<A> MyFunc();
...
std::vector<A> b = MyFunc();
As far as I understand, this copies the return value into a new vector b. Does making the function return references or something like that allow avoiding the copy?
...
I have a file that is located at a different path at development time, however at the time of release it will be in a different location. The title of the documentation, after being generated, is set to the development path. Is it possible to manually set the path of the filename?
What I mean about title:
The structure of the documented...
I am extending an existing C++ project. I have a base class that derives from two parent classes. One of the parents has a pure virtual function. I want that pure virtual function to be defined by a function implemented in the other parent.
So, I want another parent to satisfy the base class's obligation to define a parent's pure vir...
And if this is possible pleas explain how to do this.
...
I am trying to figure out if quickfix supports fpml. I am guessing not , since i could not tell by googling.
...
How to compile with another set of libraries. When I compile on i686 Fedora 13 computer, it works fine. However, when I take the executable (via thumbdrive) and try to run it on another i386 machine, I get the following error message.
/usr/lib/libstdc++.so.6: version ‘GLIBCXX_3.4.9’ not found (required by ./Recorder)
Okay, so I have t...
Hi, in the following code, I am using a pointer to a c++ string in the change() function.
Is there anyway to use the string class' operators when working with a pointer to a string? For example, at() works for the [] operator, but is there any way to use the [] operator?
#include <string>
#include <iostream>
using namespace std;
void...
How do you make .h files globally accessible by for example #include ? If its compler specific either migw or gcc. C++
...
I have the following code to get a valid file name
CFileDialog *MyDlg(new CFileDialog(FALSE,NULL,0,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,"CSV (*.csv)|*.csv||",NULL));
bool done = false;
CString sFileName = "";
while ( !done )
{
/* (Keep looping until we get a "good" filename) */
if ( MyDlg->DoModal() != IDOK )
return;
...
Was asked this in an interview, my solution kinda sucked so I am wondering if anyone can do better.
Given a URL string in this form:
http://www.foo.com?key1=value1&key2=value2&key3=value3 and given a key
I want to create a function that takes a key value and returns the original string WITHOUT the key and value.
Example:
in...
I'm wondering whether this bit of code is exhibiting the correct C++ behaviour?
class Foo
{
public:
Foo(std::string name) : m_name(name) {}
Foo(const Foo& other) {
std::cout << "in copy constructor:" << other.GetName() << std::endl;
m_name = other.GetName();
}
std::string GetName() const { return m_nam...
Greetings all,
in my application i use the following code:
bool HandleMessages()
{
MSG msg;
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
return FALSE;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return true;
}
This is the standard code for message handling in windows i though...
This is about a C++ problem.
I have an object tracking program that takes images from 0,...,n in a loop. At current frame the computations are based on previous frames, therefore I need to hold those variables, matrices, etc for later use. This program has to be integrated now into another system which will provide an image and I have to...
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main (){
int a,b;
b = 0;
cout<<" this is a family profiling program to test my knowledge of structural arrays. ";
cin>> a;
struct p {
char name[20];
int age;
char hobby[40];
char favcolor[15];
};
p family[2];
**cin.getline(family.name[0]);**
cout<<"en...
I am purchasing a comfortable laptop for development but the only operating system available to me is 64-bit (Win7) , now I am basically aware that 64-bit has 8-byte integers and can utilize more RAM, that is about it.
My programming will vary (C++, sometimes PHP) but would like to know:
Can I build my C++ application to be 32-bit por...
hello i have an error with the following code:
in my h file i got the following vector:
vector<Vehicale*> m_vehicalesVector;
and in my cpp file i got the following function:
void Adjutancy:: AddVehicale(const Vehicale* vehicaleToAdd)
{
m_vehicalesVector.push_back(vehicaleToAdd);
}
seems like the const Vehicale* vehicaleToAdd is...
Hi everyone, I am having trouble "undoing" this method, that dumps essentially a matrix of numbers of variable size into a text file:
void vectorToFile(char *name, vector<vector<double>>* a){
FILE* fp = fopen(name, "w");
for(int i=0;i<a->size();i++){
for(int j=0;j<a->at(i).size();j++){
fprintf(fp, "%f ", a->a...
Hi,
Is it possible to declare a string at all in a header (.h) file, in the definition of a Class?
When I want to set a default int, I do:
class MyClass
{
static const unsigned int kDATA_IMAGE_WIDTH = 1024;
Is there a way to do the same for the string object?
class MyClass
{
static const string kDEFAULT_FILE_EXTENSI...
I'm looking for an easy to use lib that will convert an MP3 file to a sequence of int values (and the reverse), preferable without having to dump them all into RAM. A "decode the next 16kB into this buffer" like API would be ideal.
I need C or simple C++ bindings.
A MP3<->RAW filter CLI tool would work but I'd rather not have to keep u...