I'm writing a program that converts a binary string to decimal. I wanted to validate my output before I get really started on this method. I have the following code:
int get_val()
{
int sum =0;
for(int num_bits = size; num_bits>0; num_bits--)
{
printf("String sub %i is %i\n", num_bits, int(bin[num...
If I change it to void setOutputFormat(ostream& out, int decimal_places),
with a call by reference, it works. I don't understand why though?
What is the difference between a struct and a class, besides struct members are by default public, and class members are by default private?
...
I was reading this question here here regarding const-correctness. The Scott Meyer solution seems like a good work-around, but what if you have a member function (which requires both a const and non-const version) that makes use of the this pointer. If the member function is const then this automatically means const this, which can mak...
I am writing something similar to the http://ideone.com/. Currently I am running user processes with CreateProcess call. I kill the process if it runs longer then specified amount of time but I don't know how to deny read/write filesystem rights / creating process rights etc. to the created process. The given executable can be literally ...
What is wrong wit the following constructor declaration? I keep getting this error:
Expected ')' before token '<'
class Environment{
public:
Environment(vector<vector<char> > roomData);
private:
//....
};
Note: ok I see what's wrong. I did not add: using namespace std;
...
It doesn't need to look like a progress bar.
All I need it to say is "Loading images..." while the texture is loading, then saying "Done" when it's done loading.
I have no idea, how to do it?
...
I have the following class:
#include <string>
#include <stack>
#include <queue>
#include "map.h"
using namespace std;
#ifndef CONTAINER_H_
#define CONTAINER_H_
struct PathContainer {
int x, y;
string path;
};
class Container {
public:
virtual void AddTile(string, FloorTile *) = 0;
virtual void ClearContainer() = 0;
...
Hello, I got some problem with the linked list I've written. I dunno if it's either my insert function that the problem, or if it's my traverse function that's not correct. I hope for some input. A side note, I'm initalising the list in main now since I don't know if my initNode function is correct.
#include <iostream>
using namespace ...
I have a vector object:
std::vector<std::vector<MyClass>> _matrix;
It is 2d array with some data.
When i trying to resize the dimensions with:
_matrix.resize(_rows, std::vector<MyReal>(_colms)); //_rows and _colms are ints
this command simply does nothing to the object.
So to resize it i have to call first to:
_matrix.clear();
a...
I download the file where it says 'download now' from:
http://sourceforge.net/projects/boost/files/boost/
when i unzip, there's a small .exe file. I run this (and also as administrator) a command prompt pops up and disappears instantly.
Yet everywhere i read i should be getting licence agreement etc.
Im on Win 7 64?
Help :)
...
I am getting confused as to what is the difference between the compiler and linker PDB files respectively (i.e. in Visual Studio, Project Properties > C/C++ > Output Files > Program Database File Name vs Project Properties > Linker > Debugging). I have tried to find the answer online and so far I know (may be wrong) that a PDB file by th...
Okay, I am having trouble with the following piece of code (in a header file):
#ifndef XML_H_INCLUDED
#define XML_H_INCLUDED
#include "libxml/parser.h"
#include "libxml/xmlwriter.h"
#include <string>
class XmlFile{
public:
XmlFile(string filename){
file = xmlParseFile(filename);
}
xmlDocPtr file; //Pointer to xml...
I am a little confused as to how passing pointers works.
Let's say I have the following function and pointer, and...
EDIT:
...I want to use a pointer to some object as an argument in the function.
i.e.:
void Fun(int Pointer){
int Fun_Ptr = ---Passed Pointer---;
//So that Fun_Ptr points to whatever ---Passed Pointer points...
Hi I have worked on embedded projects in c and c++ for a couple of years, never really had much of a chance to work on .net. Now can some explain to me how can i learn .Net , how long do you think it would take me to learn .Net? I look online and it seems scary, Im not even that good at c++, now there is this .net to learn. jesus.
now t...
void expand_combinations(const char *remaining_string, string const & s, int rema
in_depth)
{
if(remain_depth==0)
{
std::cout << s << std::endl;
return;
}
for(int k=0; k < strlen(remaining_string); ++k)
{
string str(s);
str.append(1, remaining_string[k]);
expand_combinations(re...
I'm very new to programming & came across a program in a book i'm reading.I get a compile error in it.
The error says "variable-sized object 'ptrFunc' may not be initialized".(it points to the end of the array)
Please advise,what is wrong in it.Thanks in advance.
#include<iostream>
using namespace std;
class cDog
{
public:
...
Hi,
There is a C code, which we are trying to convert into C++ code. There were two inheritance hierarchies, which were managed by C through switch..case. That has been converted to use virtual functions in C++. Now at one point these two hierarchies have to get related. For example class A relates to A1, class B relates to B1 .... wh...
I have been trying to read in integers from a file do some operations and output them to another file. When I input the integers into an array and then print out the result of come up with random numbers. Is this something to do with ifstream that I don't understand or am I missing something obvious?
#include<iostream>
#include<fstream>...
I have a class Helper:
template <typename T, template <typename> E>
class Helper {
...
};
I have another class template, Exposure, which is to inherit from Helper while passing itself as the template template parameter E. I also need to specialize Exposure. Thus I want to write something like the following:
template <>
class Ex...
the following code will help me illustate my question to you directly:
#include<iostream>
class foo {
public:
class bar {
public:
bar(int a) : m_a(a) {}
void say() { std::cout << m_a << std::endl;}
private:
int m_a;
};
};
int main()
{
foo::bar b(3);
b.say();
}
as you see, to declare a object of c...