- Free pool - 1 Update
- static vector (c style) - 16 Updates
"Öö Tiib" <ootiib@hot.ee>: Jan 14 02:41PM -0800 On Tuesday, January 13, 2015 at 4:44:07 PM UTC+2, Scott Lurndal wrote: > never generate a reference to the declaration, thus you'll > not get a linker error. Try compiling without -O, however > and the results may differ. I have not encountered a compiler (or linker) complaining about lack of definition of such constant unless some code tries to take address (or reference) to it (that I didn't). |
asetofsymbols@gmail.com: Jan 14 01:32AM -0800 class myVect { public: static char s_vector[50]; char us_vector[50]; static bool trunc; myVect operator=(char* s) {int i; for(i=0; i<49 && s[i]!=0; i++) s_vector[i]=us_vector[i]=s[i]; s_vector[i]=us_vector[i]=0; trunc=(s[i]==0?0:1); return *this; } }; |
asetofsymbols@gmail.com: Jan 14 01:57AM -0800 myVect& operator=(char* s) {int i; for(i=0; i<49 && s[i]!=0; i++) s_vector[i]=us_vector[i]=s[i]; s_vector[i]=us_vector[i]=0; trunc=(s[i]==0?0:1); return *this; } }; |
asetofsymbols@gmail.com: Jan 14 02:53AM -0800 Paavo wrote: class myVect { private: static std::string s_vector; std::string us_vector; public: myVect& operator=(char s[]) { s_vector = us_vector = s; return *this; } // ... hth Paavo #static std::string s_vector; #how a c++ string #one resizing object #can be static? #for me static means that I #in .exe result of compilation #can identify one piece of that #file contain space for that #string... |
jak <please@nospam.tnx>: Jan 14 12:50PM +0100 Il 13/01/2015 20:21, Paavo Helde ha scritto: > ^^^^^^ > Cheers > Paavo Yes, this is true but I've only used to joke with Richard, who accused me of writing like C. So to avoid the use of the function strlen, I thought to use that recast. :) I do not speak good English, so I struggle to explain to you just to observe the class. I wrote the function only to test the class and I use strings for simplification only. Into the program, they will be replaced by an array of structures like this: /* C style */ struct { int id; int pnumber; unsigned long dev_num; ... char name[64]; } myStructure[32]; And then, try to be understanding with me. I have written programs using the C language for a quarter century. Best Regards. |
asetofsymbols@gmail.com: Jan 14 04:38AM -0800 Jak wrote: class myVect { public: static char s_vector[50]; char us_vector[50]; static bool trunc; myVect operator=(char s[]) { trunc = (((string)s).length() + 1 > sizeof s_vector) ? false : true; for (int i = 0; i < sizeof s_vector; i++) s_vector[i] = us_vector[i] = s[i]; return *this; } }; char myVect::s_vector[50]; bool myVect::trunc; void f(void) { static myVect m1, m2; m1 = "Mickey Mouse"; m2 = "Donald Duck"; cout << "s: " << m1.s_vector << " us: " << m1.us_vector << endl; m1 = m2; cout << "s: " << m1.s_vector << " us: " << m1.us_vector << endl; system("pause"); return; } #this code here not compile #and I think should not compile #the copy string algo is wrong #the static is not good used etc #[at last for compiler I use] #people question on some macro #I used I make question on #how people like you write code #difficult what it is 100% plain #easy it is not matter the language #one write |
Louis Krupp <lkrupp@nospam.pssw.com.invalid>: Jan 14 08:36AM -0700 On Wed, 14 Jan 2015 02:53:44 -0800 (PST), asetofsymbols@gmail.com wrote: >#can identify one piece of that >#file contain space for that >#string... The keyword "static" is "overloaded." This might help explain it better than I can: http://www.cprogramming.com/tutorial/statickeyword.html Louis |
jak <please@nospam.tnx>: Jan 14 06:31PM +0100 > } > #this code here not compile > #and I think should not compile Perhaps does not compile because the example I have not left the various files included: #include <stdio> #include <string> #include <iostream> using namespace std; I have not included them because I saw that nobody does this. ...or because the main function is absent but it is only written in this way: main() { f(); } However I can assure you that what I have written compiles and runs. I'm using the compiler of visual studio express 2013. > #the copy string algo is wrong > #the static is not good used etc forgive me for my english, but this part is not clear for me > #[at last for compiler I use] > #people question on some macro ----- > #difficult what it is 100% plain > #easy it is not matter the language > #one write What can I answer you? In reality what I would like to ask you is much more complicated then I try to cut the problem into smaller pieces and understand something of each piece. :( you could see with your own eyes how difficult it was for me get answers to simple questions. regards. |
Christopher Pisz <nospam@notanaddress.com>: Jan 14 12:38PM -0600 On 1/13/2015 5:24 AM, jak wrote: > way of writing code because it is too similar to the C code and if he > does not accept that the true power of C++ is C, then he can leave the > C++ and choose for him any other OOP language. The true downfall of C++ is C. Power my arse. 80% of the bugs I encounter in bug trackers stem from C-style code from people with that mentality whom refuse to move on. |
Paavo Helde <myfirstname@osa.pri.ee>: Jan 14 12:42PM -0600 > ...or because the main function is absent but it is only > written in this way: > main() { f(); } If you want more and better feedback it is a good idea to provide compilable examples. > you could see with your own eyes how difficult it was for me get > answers to simple questions. What do you mean? Your first questions were answered immediately by Victor Bazarov, and your later posts mostly lacked any questions whatsoever. Sorry, we are not mentals here, if you don't ask any questions nobody can answer them! Cheers Paavo |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 14 07:14PM On Wed, 2015-01-14, Christopher Pisz wrote: >> Il 12/01/2015 21:16, Melzzzzz ha scritto: >>> On Mon, 12 Jan 2015 17:09:43 +0000 (UTC) >>> legalize+jeeves@mail.xmission.com (Richard) wrote: ... >> A C compiler does not compile those lines of code while a C++ compiler >> can. He tells lies. He probably wanted to say that he does not like that >> way of writing code because it is too similar to the C code Probably it's not the /similarity/ per se, but the waste ... why not use the tools available to you? They're decades old, so not having time to learn them is a poor excuse. > The true downfall of C++ is C. Power my arse. > 80% of the bugs I encounter in bug trackers stem from C-style code from > people with that mentality whom refuse to move on. If you want to go philosophical, the true power of C++ is to understand C, accept its good and bad sides, and move on using C++, while keeping the good aspects of C in mind. I see C++ as a language which fixes the obvious flaws in C -- and I see C as a crippled and, in 2015, unnecessary (but not useless) dialect of C++. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
asetofsymbols@gmail.com: Jan 14 12:36PM -0800 Yes if I add the headers all compile well... But for me the code it is too obscure... I'm not so expert So I post how I would write it in the way I understand some thing... #include <stdio.h> #include <string.h> #include <iostream.h> class myVect { public: static char s_vector[50]; char us_vector[50]; static bool trunc; myVect operator=(char s[]) {int i; trunc = (((string)s).length() + 1 > sizeof s_vector) ? false : true; for (i = 0; i < sizeof s_vector; i++) s_vector[i] = us_vector[i] = s[i]; return *this; } }; char myVect::s_vector[50]; bool myVect::trunc; int main(void) { static myVect m1, m2; m1 = "Mickey Mouse"; m2 = "Donald Duck"; cout << "s: " << m1.s_vector << " us: " << m1.us_vector << endl; m1 = m2; cout << "s: " << m1.s_vector << " us: " << m1.us_vector << endl; system("pause"); return 0; } __________________________________ #include <stdio.h> #include <iostream.h> char s_vectors[50*50]; // 0..2499 int index=0; /* index 0..49 50 string static of max 50 chars */ class myVect {public: char* s_vector; int trunc; char us_vector[50]; myVect() {s_vector=(char*)s_vectors+(50*index); if(index>=2449) index = 0; else index+=50; } ~myVect(){} myVect& operator=(char* s) {int i; for(i=0; i<49 && s[i]!=0; i++) {s_vector[i]=s[i]; us_vector[i]=s[i];} s_vector[i]=0; us_vector[i]=0; trunc=(s[i]==0?0:1); return *this; } myVect& operator=(myVect& m) {int i; for(i=0; i<50; ++i) { s_vector[i]= m.s_vector[i]; us_vector[i]=m.us_vector[i]; } trunc=m.trunc; return *this; } }; int main(void) {myVect m1, m2; m1 = "Mickey Mouse"; m2 = "Donald Duck"; cout<<"s: "<<m1.s_vector<<" us: "<< m1.us_vector<<endl; m1 = m2; cout<<"s: "<< m1.s_vector<<" us: "<< m1.us_vector<< endl; return 0; } |
asetofsymbols@gmail.com: Jan 14 12:58PM -0800 asetofsymbols wrote: > s_vector=(char*)s_vectors+(50*index); it should be : s_vector=(char*)s_vectors+index; Excuse if the copy -paste put many blank lines I not seen them |
jak <please@nospam.tnx>: Jan 14 10:24PM +0100 Il 14/01/2015 19:42, Paavo Helde ha scritto: >> main() { f(); } > If you want more and better feedback it is a good idea to provide > compilable examples. ok. I will keep your words as a treasure for the next time. thank you. > questions nobody can answer them! > Cheers > Paavo In truth I had trouble figuring out who I answered and if answered me. So I abandoned the browser and used a program that would manage newsgroups with trees. This is because Here there is the strange habit that when you talk to a person, the answer comes from another person. The impression is ugly. You feel a prey in the middle of a pack of wolves. |
jak <please@nospam.tnx>: Jan 14 10:38PM +0100 Il 14/01/2015 19:38, Christopher Pisz ha scritto: > The true downfall of C++ is C. Power my arse. > 80% of the bugs I encounter in bug trackers stem from C-style code from > people with that mentality whom refuse to move on. I am really sorry to note that you can not believe that is true the opposite. I also think that you were very unlucky to have to put your hands in the code who have written clueless. regards |
jak <please@nospam.tnx>: Jan 14 10:42PM +0100 > s_vector=(char*)s_vectors+index; > Excuse if the copy -paste put > many blank lines I not seen them right now I was picking up your code in an editor to compact it. :-) |
jak <please@nospam.tnx>: Jan 14 11:09PM +0100 Il 14/01/2015 22:38, jak ha scritto: > opposite. I also think that you were very unlucky to have to put your > hands in the code who have written clueless. > regards Excuse me but I rewrite the phrase. What is written is not what I meant: I'm really sorry that you can not believe that the opposite is also true and I also think that you were very unlucky to put your hands in the code which was written by people incapable. (I write English helped by google translator and sometimes the result is different from what I want to write. sorry.) |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment