I want to be able to add scripting functionality to my application. One of the language bindings I am considering is C# (and possibly VB.Net).
The challenge is this:
My application is developed in C++
My application runs on Linux
I am aware of Mono, but I dont know (as yet), what is required to allow my C++ appliaction (running on l...
Example:
enum Flags
{
A,
B,
C,
D
};
class MyClass
{
std::string data;
int foo;
// Flags theFlags; (???)
}
How can I achieve that it is possible to set any number of the "flags" A,B,C and D in the enum above in an instance of MyClass?
My goal would be something like this:
if ( MyClassInst.IsFlagSet( A ) )...
Is there a way to forward-declare the HINSTANCE type from the WinAPI without including the full (and big) windows.h header?
For example, if I have a class RenderWindow which owns an HINSTANCE mInstance, i will have to include windows.h in RenderWindow.h. So everything that needs RenderWindow also has to include windows.h.
I tried inclu...
I can extract 32*32 icon image, but how about 48*48.
I want to extract an icon image with size 48*48 frome an a .exe file in Windows. At first i got the icon resource bits and then i used "CreateIconFromResourceEx" API, but it works true for icon image with size 32*32.
...
can anyone help me make this more generalised and more pro?
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
// open text file for input:
string file_name;
cout << "please enter file name: ";
cin >> file_name;
// associate the input file stream with a text file
i...
Having code:
Date::Date(const char* day, const char* month, const char* year):is_leap__(false)
{
my_day_ = lexical_cast<int>(day);
my_month_ = static_cast<Month>(lexical_cast<int>(month));
/*Have to check month here, other ctor assumes month is correct*/
if (my_month_ < 1 || my_month_ > 12)
{
throw std::ex...
I have some data structures:
all_unordered_m is a big vector containing all the strings I need (all different)
ordered_m is a small vector containing the indexes of a subset of the strings (all different) in the former vector
position_m maps the indexes of objects from the first vector to their position in the second one.
The string...
Hey guys
sorry to be asking this kind noob question, but because I really need some guidance on how to use Multi probe LSH pretty urgently, so I did not do much research myself. I realize there is a lib call LSHKIT available that implemented that algorithm, but I have trouble trying to figure out how to use it.
Right now, I have a few ...
Is there any way I can construct an new object from the given object if the template parameters of both objects are identical at run-time? For example:
I have a template class with the declaration:
template<typename _Type1, typename _Type2> class Object;
Next, I have two instantiations of the template:
template class Object<char, in...
What is good book for industry level C++ programming?
I am not looking for a beginners C++ book that talks about datatypes and control structures. I am looking for a more advanced book. For example, how to build system applications using C++.
Any kind of guidance will be very helpful.
...
I have a class Model:
class Model
{
...
boost::shared_ptr<Deck> _deck;
boost::shared_ptr<CardStack> _stack[22];
};
Deck inherits from CardStack.
I tried to make _stack[0] point to the same thing that _deck points to by going:
{
_deck = boost::shared_ptr<Deck>(new Deck());
_stack[0] = _deck;
}
It seems that t...
Here is my code that fails:
bool Table::win(const Card &card) {
for (int i = 0; i < cards.size(); i++)
if (card.getRank() == cards[i].getRank()) return true;
return false;
}
Error message is: passing 'const Card' as 'this' argument of 'int Card::getRank()' discards qualifiers.
When I get a copy of the card and change the...
I need to write a C/C++ function that would quickly check if string ends with one of ~1000 predefined suffixes. Specifically the string is a hostname and I need to check if it belongs to one of several hundred predefined second-level domains.
This function will be called a lot so it needs to be written as efficiently as possible. Bitwis...
Ok, this is a really weird one.
I have an MPI program, where each process has to generate random numbers in a fixed range (the range is read from file). What happens is that even though I seed each process with a different value, and the numbers generated by rand() are different in each process, the expression to generate the random num...
Hi,
I am writing a query processor which allocates large amounts of memory and tries to find matching documents. Whenever I find a match, I create a structure to hold two variables describing the document and add it to a priority queue. Since there is no way of knowing how many times I will do this, I tried creating my structs dynamical...
I am trying to figure out why my function to open a file is failing this autograder I submit my homework into. What type of input would fail here, I can't think of anything else?
Code:
bool openFile(ifstream& ins)
{
char fileName[256];
cout << "Enter board filename: ";
cin.getline(fileName,256);
cout << endl << fileName << endl;...
The following code, prints out
Derived
Base
Base
But I need every Derived object put into User::items, call its own print function, but not the base class one. Can I achieve that without using pointers? If it is not possible, how should I write the function that deletes User::items one by one and frees memory, so that there should not...
I have been working on this for 24 hours now, trying to optimize it. The question is how to find the number of trailing zeroes in factorial of a number in range of 10000000 and 10 million test cases in about 8 secs.
The code is as follows:
#include<iostream>
using namespace std;
int count5(int a){
int b=0;
for(int i=a;i>0;i=...
Hi,
I am novice to rapidXML but first impresion was not positive, I made simple Visual Studio 6 C++ Hello World Application and added RapidXML hpp files to project and in main.cpp I put:
#include "stdafx.h"
#include < iostream >
#include < string >
#include "rapidxml.hpp"
using namespace std;
using namespace rapidxml;
int main ( )
{...
Input(text): DEADBEEF
Output(4 bytes array): DE AD BE EF
How to do this?
...