|
hi everyone,
i have one more problem in my program.. how to define and declare the new function. because in VC++ many sourcr filesand many header file are there know so i am in confusion that in which file i have to define and declare the function. dont think that these are silly ot u guys but i am fresher 2007 passed out BE.so please help me out.please send me the fomat..
thanu in advance,
savitri
savitri
|
|
|
|
|
(1) You really need good C++ book.
(2) Usually function declarations go inside header files (.h), function definitions go inside source files (.cpp).
for instance (header file):
int square(int x);
(source file)
#include <iostream>
#include "myfun.h"
void main()
{
int n;
n = 5;
std::cout << "square of " << n << " is " << square(n) << std::endl;
}
int square(int x)
{
return x*x;
}
</iostream>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: (1) You really need good C++ book.
even a C book would do.
CPallini wrote: // file myfun.h
int square(int x);
to be exact, the header file should be:
#pragma once //or anything similar
int square(int x);
for my part, i'd even prefer to see the function delaration in its own header (like you do), but its definition in another compilation unit than main()...
but that's a matter of taste
anyway, the OP seriously need to learn C/C++ before asking such questions !
|
|
|
|
|
(1) Welcome back toxcct.
(2) The OP asked about C++ .
toxcct wrote: to be exact, the header file should be:
toxcct wrote: for my part, i'd even prefer to see the function delaration in its own header (like you do), but its definition in another compilation unit than main()...
(3) if you have one header file and one source file, as in my oversimplified model, then you have to put main inside the source and don't need to protect the header against multiple inclusion .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
savitri wrote: i have one more problem in my program.. how to define and declare the new function.
uh... I hate to burst your bubble... but that sounds like more than "one more problem"... Get a C/C++ primer if you can afford it, or start visiting the online tutorials on the web. That is one big problem to start with.... I am well, speechless, and that is saying something!!!
http://www.cplusplus.com/doc/tutorial/[^]
http://www.cplusplus.com/doc/tutorial/functions.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
u all are telling that read c++ and then do programming i agree for that but i know c++ i am learning VC++ in vc++ many source files and many header files are created when we create the project so in that no main function is there so where shall i add the defination and declaration of the function. please give some hints..
for ex:
in source files
>x.cpp
>xdlg.cpp
>
and in header files
>x.h
>xdlg.h
please help me out
thanku in advance,
savitri
|
|
|
|
|
savitri wrote: but i know c++
I'm sorry to chatter your dreams but you don't know C++, neither C. The level of questions you are asking is from somebody who comes from VB and expect everything to be the same: you don't know how to write a switch case, you don't know how to declare a function, ...
All of these things are really the basics !
I sound maybe a little bit harsh but the best thing you can do is to buy a good book about C or C++ (depends what you want to learn) and start from the begining. It may sound like loosing your time but it's not the case. You'll be far more efficient and you won't to ask thousands of questions on the message boards each time you don't understand something.
|
|
|
|
|
Wow - what could be worse than someone who has no idea, and doesn't even know that ?
Nothing wrong with being a beginner, but recognise that you are one, and take the right steps to learn some basics.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
My code is performing a lot of text parsing functions and I am looking at ways to optimize the code. Does any version of the microsoft run time libraries use MMX extensions if they are available? I guess the same question applies to the .NET framework as well.
|
|
|
|
|
A lot of MMX functions, 128 bit math and the like are intrinsics in the Visual Studio compilers, they are enabled by linking with the MSVCRT runtime but you don't need it to use them. They're also not especially well documented, search MSDN for intrinsics and keep digging.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I should have phrased my question better - what I meant was are functions such as strstr optimized for MMX?
Having searched a bit more Intel provide a library Intel Performance Primitives which may offer some hope.
modified on Tuesday, March 4, 2008 5:43 AM
|
|
|
|
|
Yes, if you want optimised standard functions that use the newer instruction, Intel libraries built with Intel's optimizing compiler backend is definitely the way to go. GNU glibc has some of the lower level i386 support functions e.g. memset written in hand optimised, GAS format, assembler but the Intel tools will optimise your whole code, post compilation.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
dear all
i am doing image processing, when i would like to convert RGB to grayscale, Y = 0.3*R + 0.59*G + 0.11*B, the error occurred below:
error C2440: '=' : cannot convert from 'unsigned int' to 'unsigned int *'?
anyone help me? thanks
Li Zhiyuan
|
|
|
|
|
The message is descriptive enough: you're trying to assign an integer to a pointer. Please post Y, R, G, B declarations for further help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You are trying to convert from a pointer to integer to an integer. And the conversion is not possible.
The error message was quite clear enough, don't you think ?
|
|
|
|
|
li zhiyuan wrote: Y = 0.3*R + 0.59*G + 0.11*B, the error occurred below:
error C2440: '=' : cannot convert from 'unsigned int' to 'unsigned int *'?
change to,
*Y = 0.3*R + 0.59*G + 0.11*B;
|
|
|
|
|
thanks friend
how to convert RGB image to grayscale and let RGB value become one value, for example, [(r,g,b),(r,g,b)]to [a,b], thanks a lot, however i tried, but can't, sorry in this area i am so weak.
Li Zhiyuan
|
|
|
|
|
you tried something and end up with error, if you can post your code, i will try to direct.
|
|
|
|
|
Hi all,
Actually i want to know that what api is used for getting installation path of currently running exe....
Thanks in advance....
|
|
|
|
|
GetModuleFileName [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hi everyone,
i am learning vc++.so i am getting some problems. please help me.
For ctr = 0 To 15
dout(ctr) = Asc(" ")
Next
For ctr = 0 To Len(strData) - 1
dout(ctr) = Asc(Mid(strData, ctr + 1, 1))
Next
this code is in VB but i am working in VC++ so i am not getting the equivalent functions please help me if anybody know. its my kind request.
thanku in advance.
savitri
savitri s p
|
|
|
|
|
What if people here don't know VB? Try to explain your problem, rather than putting up some alien code here.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
for (ctr=0; ctr <=15; ctr++)
{
dout[ctr]=' ';
}
for (ctr=0; ctr <strlen(strData); ctr++)
{
dout[ctr] = strData[ctr+1];
}
Provided dout and strData are character arrays (but if they are really character arrays, you probably don't need the above code ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Why are you encouraging that person? I'm afraid this will be come a habit and the OP will come here with VB code on a daily basis. You must answer all of that, as a punishment.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|