I've already solved a problem in a slightly different way
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
using namespace std;
class String
{
private:
std::vector<std::string> data;
public:
//default constructor
String() : data()...
Hi I am trying to overload << operator for a simple class
class String
{
private:
std::list<std::string> data;
public:
//some simple functions
}
;
Unfortunately my approach to overloading << doesn't work
inline std::ostream& operator<<(std::ostream& os, const String...
Yes but unfortunately I have to create my project compatible with an interface where indexing operator is declared in the way [rows][cols]
Regards, Martin
(OS and comp.)
using Linux and gcc
I don't quite follow the presented option. Would you mind giving a simple example? I would very much appreciate.
Regards, Martin
(OS and comp.)
using Linux and gcc
I wrote a class "matrix" which uses **double. I am trying to write an operator [][] for this class to be able to perform f.ex
matrix A;
A[1][1]=2;
Does anybody know how to overload such operator?
Regards, Martin
(OS and comp.)
using Linux and gcc
I guess that might help a bit
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
int ** matrix; /*ex 3x3*/
int *copy;
matrix=malloc(3*sizeof(int*));
for(i=0;i<3;i++)
matrix[i]=malloc(3*sizeof(int));
/*copy of 3 row*/
copy=matrix[2];
}
Regards, Martin
(OS and comp.)
using Linux and gcc
If you are running on solaris you can try http://courses.cs.tamu.edu/cpsc612/miket/notes/clock.html The other option is to use traditional clock() function. It's obviously less accurate that the ones mentioned by Salem.
This is about clock()
clock_t start, finish;
double duration...
Can somebody please tell me why the first code works and second not (of course the only difference is changing type of i var. from int to unsigned int) and maybe evaulate a solution how to change a first code using unsigned type and not receive an error.
int a[3];
a[0]=0; a[1]=1; a[2]=2...
In my code *values are initialized in following way
double *values = new double[degree+1];
But when I initialize tmp in following way double tmp=0; everything works fine. It's pretty amazing how little things can destroy the whole code :) I want to thank both of you for interest and especially...
I am writing an application which is supposed to implement polynomials. It involves dynamic memory allocation, therefore I check it with valgrind. Once I noticed the following problem and I have no idea how to fix it
double poly::operator() (const double& value)
{
double tmp;
for(unsigned...
My OS is Mandrake and I am using gcc. In the meantime I found another function
http://courses.cs.tamu.edu/cpsc612/miket/notes/clock.html
Unfortunately it doesn't work under my OS, but I've checked it under Solaris and seems to work fine. Anyway, thank you very much for your comments and...
Hi I heart that for measuring a time of loop execution in nanoseconds struct timespec could be used. However, I didn't find any info how to implement it into C code. I am wondering if it works more or less the same as clock() function
int s,f;
float time;
s=clock();
/*loop*/
f=clock()...
You can use clock() function from <time.h>
clock_t start, finish;
double duration;
start=clock();
/* your loop */
finish=clock();
duration=(double)(finish -start)/CLOCKS_PER_SEC;
If someone knows other (maybe more accurate) way to measure loop execution time, I will appreciate it cause I am...
I am trying to write a program which is going to ask all users for password. It will be a console application. I am curius if there exists a function which can modify output of a console in such way:
$./a.out
$Enter password
$******* /*We are entering f.ex tektips (7 letters) but on the screen...
The solution to ""modify"" the content of * is to allocate memory for it. (functions malloc, calloc, realloc). Personaly I prefer this solution because you don't have to declare size of the array before compilation and can increase it dynamically.
char *bar;
char *tmpbar;
bar=malloc(10/*any...
Obviously. Thank you xwb!!!!!
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char *data;
int i,r;
data=malloc(11*sizeof(char));
for (i=0;i<10;i++)
data[i]='1';
data[10]='\0';
r=atoi(data);
free(data);
return 0;
}
This unfortunately proves how lame I am and how careful...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.