So I might as well use a class. Thanks.
Type: Posts; User: Russell
So I might as well use a class. Thanks.
How does one initialize a reference within a structure?
Example:
struct _s {
char& c;
}
I'll look into those. Thanks.
Thanks for your input, all. It is a tricky one (at least for me).
Since cbuffer is a byte array (i.e. it'll containt null characters), stringstream cannot be used, as a null character terminates the stream.
It's important to note that the cast must remain unsigned, otherwise it'll overflow the characters. However, having the cast, as above, unsigned results in an error.
Error:
:!make 2>&1| tee /tmp/v748926/2
g++ -O3 -Wall -pedantic -ansi -c main.cpp
main.cpp: In function `int main()':
main.cpp:9: error: conversion from `const unsigned char[4]'
to...
What is the best way to convert an `const unsigned char []' to `std::string'?
example:
const unsigned char cbuffer[]={0x61,0x62,0x63,0x0};
std::string sbuffer=cbuffer; // error
It looks like std::string will work. Thanks for your input, ahluka.
The reason I don't want to use a string is because the data is binary and may have null characters.
Is it possible to do the following:
136 struct s
137 {
138 int a;
139 char b[a];
140 };
Also, when incrementing a variable, a+=.01 is suffice.
No, I didn't want to touch the original string. Thanks for your help.
Is there a way to terminate it at 'r' (i.e. "jar")?
Is it possible to reference (or point to) part of an array? Example:
char name[]={'b','j','a','r','n','e','\0',};
char &jar=// 'j','a','r'
That's why you don't feed them. ;o)
Perhaps just a mere pat on the head. =)
Well, that's a shame. I'll just use a for loop. Thanks, Codeplug.
From the forum index:
How do I get the for_each algorithm to use the objects function (line 17)?
1 #include <iostream>
2 #include <list>
3
4 class MyClass
5 {
6 public:
...
I understand. Thanks, CornedBee.
Do you mean that what's in perimosDatabase.cpp should be merged into perimosDatabase.hpp?
I not long ago worked out the problem was with the template, yet I'm still not quite sure what. Could you explain it some more please?
Sure it does:
3 template<class T>
4 perimos::database<T>::database()
5 {
6 }
7 template<class T>
8 perimos::database<T>::~database()
9 {
This problem has me absolutely stumped. As far as I can tell it's an include issue, but I don't know why.
perimosMain.cpp
1 #include "perimosDatabase.hpp"
2
3 class...