Forum: C++ 2 Days Ago |
| Replies: 1 Views: 142 Here is the same problem in a small program, I still haven't figured it out why it thinks that set<ElementClass, CompareClass>::iterator is a value instead of a type.
#include <iostream>... |
Forum: C++ 2 Days Ago |
| Replies: 1 Views: 142 Hey guys,
I have this code snippet:
template <typename ElementType, typename CompareClass>
struct Delegate {
virtual bool geef(const ElementType &element){
pair <set<ElementType,... |
Forum: C++ 3 Days Ago |
| Replies: 0 Views: 120 |
Forum: C++ Jun 17th, 2009 |
| Replies: 4 Views: 506 OH err, the above was a question. xD
"Can you read files larger than 2^32 bytes in a 32 bit environment with streams?" |
Forum: C++ Jun 16th, 2009 |
| Replies: 4 Views: 506 Say that's a regular int (assuming 4 bytes), you can't open files more than ~5GB in a 32-bit environment (since the stream can't be bigger than that).
Thanks for that though! I used MAX_INT... |
Forum: C++ Jun 16th, 2009 |
| Replies: 3 Views: 262 What wildgoose gives as a solution is called a "forward declaration", so you can read up about it (where what why how etc.)
And yes, Pancake stacks are most of the time FILO ones. xD ;) |
Forum: C++ Jun 16th, 2009 |
| Replies: 4 Views: 506 Hey guys,
Can I tell istream to ignore ALL the characters until the delimiter char? It can be done with a loop but it's kinda weird I can't tell istream "discard until this char" imho, so maybe... |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 862 Hey, sorry to go offtopic anilopo, but Narue reminded me,
If I have a class like this:
class X{
public:
X(int y) : y(y) {}
private:
int y; |
Forum: C++ Jun 15th, 2009 |
| Replies: 11 Views: 862 You can't call calc() in the product class. calc() isn't implemented in the Product class! ;)
What you're doing in the ctor is basically:
Product :: Product (...)
{
this->price =... |
Forum: C++ Jun 13th, 2009 |
| Replies: 2 Views: 388 Hehe, I messed up the linking order.
Say that Program A depends on Lib B, and A and B contain references to Lib C, then A needs to supply B before C, not after. |
Forum: C++ Jun 12th, 2009 |
| Replies: 2 Views: 388 Hey guys,
So I have compiled my first home-written static library (named PixGUI) that happens to call OpenGL functions. However, I noticed that when compiling (using MinGWs GCC with Code::Blocks... |
Forum: C++ Jun 12th, 2009 |
| Replies: 21 Views: 906 This might come in handy as well:
http://www.cplusplus.com/reference/std/typeinfo/type_info/ |
Forum: C++ May 27th, 2009 |
| Replies: 2 Views: 364 |
Forum: C++ May 27th, 2009 |
| Replies: 2 Views: 364 Hey guys,
Below code isn't working as I expect it to do. I expect it to read all params when 6 are given, buuuuuuuuuuuut it only reads one, the rest remains zero. It does enter the case, but the... |
Forum: C++ Apr 27th, 2009 |
| Replies: 3 Views: 776 Ugh, fixed it, I forgot the const. With normal functions the error messages are a lot clearer in GCC.. hope they "fix" this soon.
Here's the working code:
//...
private:
template... |
Forum: C++ Apr 27th, 2009 |
| Replies: 3 Views: 776 Hehe, back again. Templates are difficult if you're not precise I guess. I'm stuck on this one:
sss.hpp
#include <string>
#include <map>
#include <stdexcept>
#ifndef SSSHPP
#define SSSHPP |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 Ah, sorry. They are big functions. :) I finished the code and documented it, it's for review at my website, here's a quick link:
www.dotsimplicity.net/?p=191
Thanks for your input! That... |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 Because one reads and one writes? Hahahaha |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 I am not looking for a runtime solution, that's why I hadn't.
Here's a working example:
template <typename T>
bool read_or_write(const char *filename) {
T... |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 Oh I'm sure that doesn't work, never seen it, just made it up. But I want to know how I'd do that in C++. :D |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 Well, a design wouldn't need it. I don't know if its needed but can't you say something like: T can only be ifstream, ofstream
Code could look a bit like this:
template <typename T =... |
Forum: C++ Apr 25th, 2009 |
| Replies: 10 Views: 602 Hey guys,
How would I partially specilize a template in a manner as below? Is that even possible?
I have these two functions:
bool node::read(const char *filename) {
ifstream... |
Forum: C++ Apr 25th, 2009 |
| Replies: 3 Views: 776 Okay dat was stoopid.
node& node::child(const string name, size_t index) {
return searchInsert<string, node>(values, name, index);
}
Should of course be..
node& node::child(const string... |
Forum: C++ Apr 25th, 2009 |
| Replies: 3 Views: 776 Hey guys,
What am I doing wrong here?
sss.hpp
#include <fstream>
#include <string>
#include <map> |
Forum: C++ Apr 24th, 2009 |
| Replies: 3 Views: 499 Thanks guys, worked like a charm and I understand it too. woopiedoo. |
Forum: C++ Apr 23rd, 2009 |
| Replies: 3 Views: 499 Hey guys,
I have a class with a friend function and a member function with the same name. Calling the friend function from the member function gives me an error: it looks for... |
Forum: C++ Apr 21st, 2009 |
| Replies: 4 Views: 298 Sorry for those semi-gotos. Here are equivalent function without lazy-programmerness.
string& node::value(const string name, int index) {
using sss::value;
valueiterator it =... |
Forum: C++ Apr 21st, 2009 |
| Replies: 4 Views: 298 Hey guys,
With this defintion:
sss.hpp
#include <fstream>
#include <string>
#include <map> |
Forum: C++ Apr 21st, 2009 |
| Replies: 13 Views: 1,143 Yup, see my second post and the post with the "working code". |
Forum: C++ Apr 20th, 2009 |
| Replies: 13 Views: 1,143 main.cpp|12|note: say `typename std::vector<T,std::allocator<_CharT> >::iterator' if a type is meant|
So that's what it meant. Thanks. :)
Working code:
template <typename T>
void... |
Forum: C++ Apr 20th, 2009 |
| Replies: 13 Views: 1,143 Durr, code should be:
void kill_dupes(vector<int> &x){
vector<int> y;
for(vector<int>::iterator it = x.begin(); it != x.end(); it++){
if(find(y.begin(), y.end(), *it) ==... |
Forum: C++ Apr 20th, 2009 |
| Replies: 13 Views: 1,143 That will not do the trick: Unique only removes when consecutive duplicates are found: (http://www.cplusplus.com/reference/algorithm/unique_copy/) |
Forum: C++ Apr 20th, 2009 |
| Replies: 13 Views: 1,143 Hey guys,
I got this code, and I can't get it to compile, no clue what I'm doing wrong.
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
template <class T> |
Forum: C++ Apr 20th, 2009 |
| Replies: 3 Views: 378 Oh that back_inserter is nice. I'm reading up on the STL as of lately, so much to learn. :D Thanks Narue. |
Forum: C++ Apr 20th, 2009 |
| Replies: 3 Views: 378 Ugh. Nevermind. Forgot to allocate. That's sooooooooo C. xD
(Correct?) Working code:
int main() {
int afrom[4] = {0,0,1,2};
int ato[4] = {1,2,3,4};
vector<int> from(&afrom[0],... |
Forum: C++ Apr 20th, 2009 |
| Replies: 3 Views: 378 Hi guys,
What am I doing wrong here? Program dies on me @ merge(). :(
#include <iostream>
#include <vector>
using namespace std;
int main() {
int afrom[4] = {0,0,1,2}; |
Forum: C++ Apr 20th, 2009 |
| Replies: 13 Views: 667 Yes, that should be it. remember to use spaces tho. And put the input file in the same directory as tabu_sdvrp.exe of course. |
Forum: C++ Apr 20th, 2009 |
| Replies: 4 Views: 432 Windows has a table of resources (Windows, buttons, icons, mouse pointers, menus, etc.)
Each resource has an unique ID.
With that ID, you can get that resource, and functions that create a new... |
Forum: C++ Apr 19th, 2009 |
| Replies: 4 Views: 263 Tux4life is right, you can't delete one element of an array in C(++). Either use a vector or do as tux4life said. |
Forum: C++ Apr 19th, 2009 |
| Replies: 6 Views: 445 Your overloaded >> is a bit complicated, here's a simpler version:
int main() {
int nom, denom;
string buf;
getline(cin, buf);
stringstream ss(buf);
ss >> nom; |