51 Posted Topics
I have a type casting question. I saw method 2 in my code and it able to compile (The code is not written by me). Can I know what method2 mean? method 1 is understandable. class Base {}; class Derived : Base {}; void main () { //let say I … | |
Hi, I'm looking for embedded system or os source code example. Just to learn some common error or good way to write some device process. Probably in C or C++. Is there any good suggestion? | |
I read a sample code from a development kits. The global array is declared without indicating the array size. I wonder is it safe? Here is the code: #include <stdio.h> // For Used Function printf // UART Buffer char uart0_buf[]; // "sprint" UART[0] Buffer char uart2_buf[]; // "sprint" UART[2] Buffer … | |
I have develop a functor array without class but fail to write a functor relate to class. Here is the code without class int returnOne (void) { int a = 0; a++; return 10; } int returnTwo (void) { int a = 0; a++; return 20; } typedef int (*functor2) … | |
I'm designing a embedded system and we have to oftenly report system fault in different code module. So I decided to create a source file to keep the error log and I'm building a struct for that. So that, every module reporting the error log and store in a data … | |
I recently learn about the polymorphism and I don't know what is the purpose to use this feature. From http://www.cplusplus.com/doc/tutorial/polymorphism/ , it uses the child class rather than the parent class. I thought most of the time we inherit and we only use the parent class to access the child. … | |
Hi, I have a problem on search text from a string. I'm able to find it but my method is slow. Let say I got a string that contain items and I need to find out which items come first. So I find all the item by *.IndexOf("...").* Then find … | |
I want to convert string to unsigned short. Example "123" equal to number 123 or 0x7B. But i get an error while doing the convertion : "Error 9 Cannot implicitly convert type 'int' to 'ushort'. An explicit conversion exists (are you missing a cast?)" Here is my code: UInt16 usTest … | |
Hi, I'm facing few problem on textbox : 1. I got plenty of textbox which roughly 500+ and my design haven't done so it might grow. Each of the textbox is represent data received from serial port. To update textbox then i need to write the code line by line … | |
I got only 1 form, which use to retrieve text from a text file. After that I need to do convertion(convertion of the text file) and display(display the converted text) as well. I manage to have 4 class which are Form1.cs, Convertion.cs, Display.cs and Database.cs. So Form1, Convertion and Display … | |
I know the purpose of keyword but then I still not really know when should i use. But I sure I will optimize my code. So is it ok to i use volatile keyword on all my variables? So that it won't optimize the wrong thing. | |
The local pointer will be remove after i go out from that scope? or will remain? Example: int glb1 = 2; int main () { int var1 = 0; fnCall1(); fnCall2(); //at here } void fnCall1 () { int tmp1; tmp1 = 10000; } void fnCall2 () { int *ptr1; … | |
Hi I know it is unable to inherit 2 superclass and I know why because there is another thread discussing about this. But I just wonder is there a way to solve this problem? | |
Let say I have 9 boxes. Each box may randomly contain number 1-9.. Each box minimum contain no number, maximum contain 9 number and each box won't have duplicated number. My problem is how do I look for pairs/triple/quadruple of same number in different box. Eg. Box 1 : 1,2,5,6,7 … | |
Re: I think one of the problem is on your variable* declaration... | |
I'm using ARM nxp lpc2368. When I tried to add a assembly code in startup file. It show me a compilation error "invalid constant (e002c00c) after fixup". where the code is [CODE] mov r2, #0xE002C00C //address of PINSEL3 : 0xE002C00C[/CODE] when I refer to this link [url]http://www.ee.ic.ac.uk/pcheung/teaching/ee2_computing/arm/Refcard.pdf[/url] It said in … | |
| |
if i declare size 5 array [CODE]char ch[5]={'1','2','3','4','5'};[/CODE] Then the null will store at the address ch+5 ? even i didn't declare the size for the null to place. If so mean it may overlap value on that memory address? | |
Re: You just do your code on paper.. then you will find out already. *When you do, must follow code not follow what you planned. It's a sequence problem... | |
It's my first time to use functor. So hope can get some guide here. My program need to call different function depend on input. so i thinking to use functor to do that. e.g. main.cpp [CODE]#include "functor.h" #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { … | |
Re: You can try debug yourself by just modified your code. e.g. [CODE] for(int x=strl1; x>=0; x--){ cout<<"Current x: "<<endl; //test cout<<"=======\n"; //test sum=num2[x]+num1[x]+carry; cout<<"sum is "<<sum<<endl; //test carry=sum-10; cout<<"carry is "<<carry<<endl; //test if(carry<=0){ carry=0; sum=10%sum; } total[x]=sum; cout<<"total[x] is "<<total[x]<<endl; //test } for(int i=0; i<strl1+1; i++){ cout<<total[i]; }[/CODE] | |
I'm currently choosing which data structure to use for my data logging. Just want to ask for suggestion which type of data structure is better. It has limitation on memory either store in microcontroller RAM or SD card. - I can't know the total type of logging it has. (for … | |
Re: If you want to make 0.999 become 1 then you use ".round ". Else f you want prove it mathematically then try this [url]http://en.wikipedia.org/wiki/Limit_(mathematics[/url]). Write your code for this equation. I never try. XD | |
Re: This is the way to use constructer [url]http://en.wikipedia.org/wiki/Constructor_(object-oriented_programming[/url]). | |
Re: go step by step debug yourself. You can put cout for your interest/principle/moneyowned in every loop. So you can find out which is the error. | |
Re: normally i do that with string. So user can enter whatever length/alpha/number they want. After that only write errorcheck function for the input. | |
| |
Re: Is it because [CODE]void computeSum (vector<int> &Vec, int howMany, int total, bool success) cout << "Your total is " << computeSum(dataVec, howMany, total, success);[/CODE] has no return? | |
Re: while( /*condtion of getch() is a ASCII enter */ ) {} | |
Re: you have a same condition run through twice in a loop. So in the second condition will overlapse the first condition | |
I having problem of sizeof returning a hexadecimal value which I want it return decimal here is my sample code: [CODE]#include <cstdlib> #include <iostream> #include "stringCascade.h" using namespace std; void StringCascade (void) { unsigned char ucA[] = {0x02, 0x6F, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, … | |
[CODE]union _Test { unsigned char keydata[4]; struct _Member { unsigned char a; unsigned char b; unsigned char c; unsigned char d; }Member; }Test; Test.keydata[4]= { 1, 2, 3, 4}; [/CODE] error on line 12: expected expression before '{' token. If I declare without union, [CODE]const unsigned char keydata[NUM_KEYS]={ 2, 1, … | |
let say i have a class A (base) class B , C, D also inherit A [ multiple ] then class E inherit class B, C, D... But class E also want to inherit class A [ multilevel ] *I want to use class A protected function in class E... … | |
Re: [QUOTE=fonzi;1518701]To install from a pen drive a.k.a usb flash drive Ubuntu.com has a great tutorial [URL="http://www.ubuntu.com/desktop/get-ubuntu/download"]http://www.ubuntu.com/desktop/get-ubuntu/download[/URL] here the link above and scroll down to step 2, choose weather you wish to create a cd or USB pen drive, it will give you detailed instructions on how to create a bootable … | |
I'm new on using class. Other than declare as friend class or declare static for the specific file to share variables/functions. Is there any other way? I have inherit few classes and wrote into few *.cpp file. I can't extern a static file, so is that mean i just only … | |
I'm using eclipse C++ helios and mingw compiler... I created a hello world project without modify the original code.. It compile successfully but when i click run, it show terminated test.exe I'm new to use eclipse IDE, so hope to get some helps here.. thanks | |
| |
Re: Do you mean you want to input a set of data, and then output to excel spreadsheet? If so i did something like this before, you can use fstream to outfile with file extension *.csv. Use comma to next column and endline to next row. | |
Re: if you are using windows then can you use [CODE]system("exit");[/CODE]. The content inside the bracket of system() is your command prompt instruction. | |
i searched about this error. they said is mostly caused by forgot putting semicolon... but i find for 1hours+ still cant find out >.< anyone can help me? the error is pointing test.h lines 9: multiple types in one declaration test.h: [CODE]#ifndef TEST_H_ #define TEST_H_ class TEST { public: //call … | |
our arm9 board kernel os version is just able to support 2.6.13 or below. and we fail to update the new kernel os version. So we decide to find a arm-linux-gcc version that fit the kernel os version. Anyone knows which arm-linux-gcc version fit? we tried arm-linux-gcc 4.4.3 and 4.3.2. … | |
I'm newbie on arm9 and linux OS. I hope i can get some clue how to start on interact between my pc and arm board. Im using ubuntu 10.10 and i haven download the arm-linux-gcc yet. I have a OSAP L138 with ARM 9. I can successfully power on and … | |
Re: [CODE]#include <iostream> #include <string> using namespace std; int main(void) { string name; string name2 = "Test"; cin>>name; cout<<"string : "<<name<<endl; name.append(name2); cout<<"string : "<<name<<endl; system("pause"); return EXIT_SUCCESS; }[/CODE] this work to for using string lib | |
[B]In main.cpp[/B] [CODE]#include <iostream> #include "init.h" using namespace std; Initialization Init; int main() { Init.test(); return 0; } [/CODE] [B]In init.cpp[/B] [CODE]#include <iostream> using namespace std; class Initialization { public: void test() { for(int i=0; i<10; i++) { cout<<i; } } };[/CODE] [B]In init.h[/B] [CODE]#ifndef INIT_H_ #define INIT_H_ class Initialization … | |
I searched from internet. They said have 2 ways to create sub-function file, first way is : using header file which is easier to write. second way is: using cpp file which will increase the compilation time. But my lecturer say using header file to write sub-function is a wrong … | |
Re: i tested and it work.. which part you not confident? | |
Re: Two ways: 1. using class: declare midPointX and midPointY as public int, then it can be access from other class or main. 2. return x*1000 +y. Then when you getting the value, you have to undo the process to get back two values x and y. |
The End.