...&str)
{
std::list<std::string>::iterator idx;
idx=(str.data).begin() ;
//for(idx=str.data.begin(); idx!=str.data.end(); ++idx)
os<<*idx<<endl;
return os;
}
The error is as following
error: no match for ‘operator=’ in ‘idx = str->String::data. std::list<_Tp, _Alloc>::begin...
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
...It's obviously less accurate that the ones mentioned by Salem.
This is about clock()
clock_t start, finish;
double duration;
start=clock();
/* your loop */
finish=clock();
duration=(double)(finish -start)/CLOCKS_PER_SEC;
Also here are some links to similar topics...
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...
...and I have no idea how to fix it
double poly::operator() (const double& value)
{
double tmp;
for(unsigned i=0;i<=degree;i++)
tmp+=values[i]*value;
return tmp;
}
ostream & operator << (ostream & o, const poly & p)
{
for (unsigned i=0;i<=p.degree;i++){
o << p[i];
o <<...
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...
...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();
time=(f-s)/CLOCKS_PER_SEC
or maybe totally different. Also what libraries should I include. I am pretty sure that <unistd.h>...
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...
...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 we see 7 stars*/
Thanks in advance for any help.
Martin
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.