CPallini wrote:
Oh, no : too complex, both in space and time. Big Grin
really? but I dont think it is toooooo complex... :laugh:
CPallini wrote:
Oh, no : too complex, both in space and time. Big Grin
really? but I dont think it is toooooo complex... :laugh:
u need this [^]
ohhh... I tried dis...but I didnt get wot I wanted exacly..
Is their any standard formula to calculate time and space complexity of algo or please give me link to all above things r given..
Joe Woodbury wrote:
I don't understand why you are using a void*
Just I wanted to check that is is possible to print array using void*, You helped me a lot and I Could, thanks. Last one Q.:
ptr = (int*)ptr + 1;
In this case,I don't understand why you incremented by 1, size of int is 2, ptr is void* but we are converting it into int so suppose to be incremented by 2; but it fails and how above code works fine ?
Joe Woodbury wrote:
The point is that you could do *(int*)ptr.
is working fine, But I want to print array so I tried following code which is not working, So can you please make it workable.
int arr[]={10,20,3,6};
void *ptr=(void *)arr;
int i=3;
while(i--)
{
printf(" %d",(*(int *)ptr));
(int *)ptr+=2;
}
Joe Woodbury wrote:
printf expects you to pass a value as an argument. By definition you can't resolve a void pointer.
Agree with you..:thumbsup:
Joe Woodbury wrote:
Be happy;
Here too...:thumbsup: BUT,
Joe Woodbury wrote:
in the past the compiler wouldn't stop you from being stupid.
Is this solution to the problem I asked? :sigh:
To print array compiler giving error: I tried following code but It is not working,
int arr[]={10,20,3};
void *ptr=(void *)arr;
printf("%d",*ptr); // getting error on this line
So, please any suggestion to print array using void pointer, And most imp why compiler not allowing above code .. :confused:
How can I store address of integer array to void pointer and print array using void pointer?
who is lying compiler or you?..but I should believe in compiler and it says that error: c:\test.cpp 6: cannot initialize class member here
try this code
class temp
{
static const int i=10;
};
void main()
{
}
yes.. it's
if(function)
and thanx ..I got it.
what happens with if condition in following code?
int function(int i)
{
printf("inside function");
return 0;
}
int main()
{
if(function)
printf("hi");
else
printf("bye");
}
and output is only hi why compiler doesn't complaints about wrong function call? :confused:
modified on Thursday, July 23, 2009 12:08 PM
from above discussion I have come to conclusion that compiler does not allow any type of initialization in class, so statement
static const int c = 299792458;
in your code also creating problem... :(
This is working fine
MyClass::MyClass() : myConstInt(5)
{
}
but it is not possible,
class MyClass
{
const int myConstInt = 5;
}
compiler is giving error, So I guess only one way to initialize const in a class..
Is it possible to declare member variable of class as a const, if yes,please give me 1 example how to initialize it and if not, why?
[Message Deleted]
but if your are assigning any thing to any variable(in our case a=0), this statement suppose to a true, and a=1 does, but what is wrong with zero?
Can anybody tell me why value of b is 3 in this code? what happens with (a=0) exactly?
int a=0;
int b=(a=0)?2:3;
cout<
Thnx very good link....i got many things cleared :)
why we can't overload .,->, :: operators?