202 Posted Topics
Re: http://www.cplusplus.com/forum/windows/39170/ but learn more about [recursive functions](http://www.danzig.us/cpp/recursion.html) don't forget the recursive functions are functions that call them selfs, never forget put an if for close them or it can takes several memory or even more problems | |
| |
when we overloading a function: what matters is only the argument list(inclued the types) or the return type too? i'm overloading the assigment operator, but seems that i can't use with diferent return types:( please someone explain to me | |
can i create 1 template that i use inside the class and not when i create the class object? | |
cout << *static_cast<int*>(test); test is a void pointer pointed to an int variable. if i use: cout << *static_cast<char*>(test); i get just 1 character. so how can i print the value directly to string? if i use the string i get an memory error | |
i know: - &varname is the adress of varname; - *varname is the value of adressed variable. but: void *Vvariant=NULL; friend ostream& operator <<(ostream &os,const variant2 &obj) { os << obj.Vvariant; //how can i get the value of adressed variable? return os; } how can i get the value of … | |
heres my variant class: // *** ADDED BY HEADER FIXUP *** #include <cstdlib> #include <iostream> #include <string> // *** END *** #ifndef VARIANT_H_INCLUDED #define VARIANT_H_INCLUDED class variant { string a=""; public: variant (string value="") { a=value; } variant (double value) { a=to_string(value); } friend istream& operator >>(istream &is,variant &obj) { … | |
//write void write() { setlocale(LC_ALL, "en_US.UTF-8"); cout <<""; } template <typename A, typename ...B> void write(string argHead, B... argTail) { setlocale(LC_ALL, "en_US.UTF-8"); if (blnBlink==true) { CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); string a; a=argHead; TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes); COORD Position; Position.X=csbi.dwCursorPosition.X+strlen(a.c_str()); Position.Y=csbi.dwCursorPosition.Y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position); } else cout << argHead; write(argTail...); } template <typename A, … | |
the function is a std::function<void(string a) write; ok.... it's void.... but why the error about it??? what means these error? | |
i understand that the macro is a code that is changed before compile it. so i did these macro with these code: #define (events2((y),(x))) (class events3 : public ( y ) { events3(); ~events3(); }(x) ; ) //#define (events2((y),(x))) (class events3 : public ( y ) { events3(); }(x) ; … | |
see these class: class test { public: void Created(){}; test() { Created(); } }; now we can create objects from it. ok. but can i overloading the scope-resolution ('::') for the object accept and change the Created() function? | |
when we create the window, we can choose some styles. but i see 2 problems: - how can i hide the border?(i have seen the msdn styles, but theres no const for that) - how can i change the styles after create the window? | |
i'm learning win32 from: http://www.winprog.org/tutorial/start.html but tell me(because i ear several persons) is these function correct? LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } the DefWindowProc() is … | |
how can i test if the wheel move was negative or positive? i belive these detect the mouse position: xPos = GET_X_LPARAM(lParam); yPos = GET_Y_LPARAM(lParam); but how can i test if any key(like alt\control\shift) was pressed? (i'm talking in same message) | |
see my windows procedure: LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { bool blnMouseEnter=false; switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_KEYUP: if (wParam ==VK_ESCAPE) DestroyWindow(hwnd); else { char strDataToSend[32]; sprintf(strDataToSend, "%c", wParam); MessageBox(NULL,strDataToSend, "keyselected",MB_OK); } break; case WM_MOUSEMOVE: SetWindowText(hwnd,"hi"); break; case WM_MOUSELEAVE://is ignored :( SetWindowText(hwnd,"bye"); break; … | |
i'm building a class with std::function for recive several parameters or none: class event2 { public: typedef std::function<void(...)> OnSomethingHandler; void operator() (...) { eventwithoutarg (...); } event & operator = (OnSomethingHandler Handler(...)) { eventwithoutarg(...) = Handler(...); return *this; } private: OnSomethingHandler eventwithoutarg(...); }; what i'm doing wrong with '...'? | |
see these sample: template <typename a> class test { test(a argument) { cout << argument; } }; //declare it: int main() { test<string> a("hello"); } how can i do it: test a("hello"); | |
template <typename a, typename ... b> class events { public: typedef std::function<void( a arg, b ... argx)> OnSomethingHandler; events(OnSomethingHandler Handler) { handlers_.push_back(Handler); } void operator ()() { for(auto i = handlers_.begin(); i != handlers_.end(); ++i) (*i)(); } private: std::vector<OnSomethingHandler> handlers_; void AddHandler(OnSomethingHandler Handler) { handlers_.push_back(Handler); } void TriggerEvents() { for(auto … | |
the csbi.wAttributes are combinations of '|' operators,... DWORD textcolor = csbi.wAttributes & 0xff0f; DWORD backcolor = (csbi.wAttributes & 0xfff0) >> 4; i understand the 0xff0f is a hexadecimal value(i don't know in decimal), but why these number and not other? can anyone explain to me these 2 calculations? (they are … | |
i have these code for clear the screen: //clear the Console void Clear(int BackColor=0) { // home for the cursor COORD coordScreen = {0, 0}; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; // Get the number of character cells in the current buffer if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) return; dwConSize = csbi.dwSize.X * csbi.dwSize.Y; … | |
the prototype function is: BOOL WINAPI WriteConsoleOutputAttribute( _In_ HANDLE hConsoleOutput, _In_ const WORD *lpAttribute, _In_ DWORD nLength, _In_ COORD dwWriteCoord, _Out_ LPDWORD lpNumberOfAttrsWritten ); i'm trying use it for the 1st time... what means: "lpNumberOfAttrsWritten [out] A pointer to a variable that receives the number of attributes actually written to … | |
i know use SetConsoleTextAttribute(): SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) ); (too be honest: i don't have sure if i can avoid the '<<4') i need ask these: can i add it more data and then use it? like: Blink=128 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) | Blink); and then test if these value is there? | |
by some reason the TextOut() function don't show me the text:( but see these code: #include <iostream> #include <string.h> #include <windows.h> using namespace std; int main() { HDC a=GetDC(GetForegroundWindow()); cout << GetLastError();//i get 0(no errors) Rectangle(a,3,4,3+80,4+20);//the rectangule is showed TextOut(a,10,10,"hello world",strlen("hello world")); cout << GetLastError();//i get 0(no errors) cin.get(); } … | |
i have 1 class Multithread, but seems that i have some errors:( #include <process.h> #include <string> using namespace std; class MultiThread { private: void * b; public: void ParameterList(void *c) { b=c; } void Thread(unsigned (__stdcall*) (void *) ) { _beginthreadex(NULL, 0, (__stdcall*) (void *) , b, 0, NULL); } … | |
can anyone explain to me what is: 'T', 'L', 'wchar_t', 'LPCWSTR' and 'LPCTSTR'? how can i convert strings\char* to these types? (i understand these isn't a tutorial, but i realy need these introdution) or you can give me just a nice link. | |
imagine these line: cout << "glória vitória"; //glory vitory why instead print 'ó', prints '3/4'(the ascii char)??? changing the console font name, can resolve it? | |
if C++ isn't a real OOPL, what left? with another words i want study(theory\concepts) the real OOPL. can you give me a link with these information? | |
on my last topic i didn't recive mails notifications(when someone answer me). how i have sure that i will recive a mail notification on topic? | |
when i enter on windows, i see the button user name... until here, fine. but when i click it, i get 1 error about user profile. can anyone help me fix it, please? | |
is there any function(API or something) for get 1ms of precision? i have 1 timer, but i only get 10ms of max. | |
Re: just for test these: #ifndef DUMMY_H #define DUMMY_H #include <iostream> #include <Magick++.h> #include <zbar.h> #include <highgui.h> #include <cv.h> using namespace std; using namespace zbar; using namespace cv; class dummy{ public: dummy(); }; #endif // DUMMY_H tell me if you don't get any errors | |
Re: maybe these can helps: const int BLACK = 0; | |
Re: you can open the .cpp file with notepad. maybe these helps you | |
Re: cout print something on console screen. in these case will print '5', because 5.0/2 will be 2.5(because the 1st number will be considered float\double), and multiply by 2 will be 5. anotherthing: the '()' is more important on math than '*'. it's the operations order sequency like math. i hope … | |
see these class: class test { public: void virtual Created(){} void test() { Created(); } }; class test1 : public test { void Created(); void test1(): test { Created(); } } test1; void test1::Created() { cout << "created test1"; } (these code wasn't tested, but you get the point) can … | |
class test { virtual void created(){}; //i must do these. //or when i call the function the compiler give me an error test() { void created(); } }test; void test::created() { cout << "hello world"; } these code have 1 error. but how can overrride the created function? | |
i want build 1 const with std::endl but by some reason isn't accepted:( #define NewLine std::endl i understand the '#define' isn't adviced to be used, but in these case i belive that i can't use the 'const':( what isn't right with that line? error message: "C:\Users\Joaquim\Documents\CodeBlocks\My Class\console.h|170|note: void Console::write(A, B … | |
i have 1 class: class class1 { void Created(); calss1() { Created(); } } class1; void class1::Created() { cout << "hello"; } imagine that i don't write: void class1::Created() { cout << "hello"; } i get an error. i try these too: class class1 { void Created() { //do nothing … | |
i build these code. it's very cool: in test.h: class test { private: bool blVisible; int x=0,y=0; public: void Show(); bool Visible() { return blVisible; } void Visible(bool value) { blVisible=value; if (value==true) Show();//call the event } }; in main.cpp: include <iostream> #include "test.h" using namespace std; test a; void … | |
using templates: how can i do a parameter for accept a function name? | |
the Visual Studio 2010 have 1 way for build properties, in class's. but isn't a portable code:( i'm using GNU\GCC\G++. so don't belive that isn't possible do it in C++;) so anyone can advice me? i was testing these code, but i get problems with char* and i can't use … | |
Re: i have 1 question: for use dynamic arrays, can i use normal variables instead pointers? | |
Re: because in line 31 you never used an 'if';) do { cout<<"How many days?"<<endl; cin>>days; if (days<0) cout<<"You enter a negative number,please try again."<<endl; }while (days < 0); i hope help you | |
i'm trying doing a static clas, but i, always get errors... now i have head pain:( class Pessoa2 { private: static string strnome; public: Pessoa2() { strnome="ana"; } void setnome(string value) { strnome=value; } static string getnome() { return strnome; } }; just seen these static class, what i'm doing … | |
i read several time about Bitwise Right Shift Operator (>>\<<) but i continue without understand them:( can anyone explain to me? i don't undertand what will be the next results:( Half = 25 >> 1; Half = 25 << 1; | |
//arr is the array int length;//for recive the array size length=sizeof(arr);//recive the array size cout <<length; length=length/sizeof(typeid(arr));//calculate the number of elements cout << sizeof(typeid(arr)); i'm using these code for calculate the number of elements in array. sizeof(typeid(arr)) these line is for give the type size, but isn't correct can anyone … |
The End.