IbrahimB's Posts
Nairaland Forum › IbrahimB's Profile › IbrahimB's Posts
1 2 3 4 5 6 7 8 9 10 (of 16 pages)
Nice one! As regards your question: why does <= generate an error?Remember that arrays (and vectors) in C++ are zero-indexed. So for an array of size = 10, the only valid indices are array[0] to array[9]. So your index always has to be < the size; obviously <= will generate an error. Secondly, you have to be careful when dealing with pointers, as they can become invalid at anytime! A useful addition to your code would be: if(Objects[i] != NULL)Or better still, you could decide to store copies of the objects themselves rather than their addresses. This makes sense since the objects are not so "heavy". You would then need copy constructors and assignment operators for that. Lastly, you can consider returning and passing your strings by reference rather than by value. It is faster as no copying is involved. std::string giveAttributes()now becomes std::string& giveAttributes(). Cheers. |
I hope they don't give birth to a Kleptomaniac. |
symbianDON:Bros, na breakfast dem talk o ![]() Ranoscky:Sounds more like Rat Poison than a Nigerian Breakfast ![]() |
@Gameaddict gameaddict:It is very important to make proper use of terminologies. When you say child class, you are referring to inheritance. A child class inherits from another class (i.e. the parent class). That was why I brought the whole issue of Stuff being a kind of Box or not. The proper term to use in your case is member class. Secondly, the issue of overloaded functions. If you're creating only one single function for registering stuffs, then overloaded function wouldn't be the right term to use. |
C# is very good to start with. You can use it for web, desktop and mobile development. It is becoming increasingly popular and there's lot of demand for C# programmers. ![]() |
gameaddict:You'll have to try out to know. ![]() What do you really need an overloaded function for? Is inheritance the best relationship to use? It seems composition and not inheritance is what you really need. If "Stuff is a kind of Box" does not sound right, then it's better you do away with inheritance. If Box is just to store stuffs, just create a vector of stuffs member, right within the Box class. Then create an "add" function for adding Stuff objects to the container. Good luck. |
enzo01:Have you tried Google? Seriously. There's a lot of information you can get from Google if you search with the right keywords. The express edition of C# is available from Microsoft for free. |
gameaddict:It shouldn't be a problem. In the example provided, 'stuffs' was declared static so that it is independent of any instance of the Stuff class. It was protected so that it's accessible to the Box class. All you need to do is to create a member method for Stuff to update 'stuffs' anytime you create an instance of the Stuff class. 'stuffs' is automatically available to the Box class. |
I guess you can do so, although it's not really clear what you want to achieve? class Stuff { protected: static vector<Stuff*> stuffs; } class Box: public Stuff { //create method to access "stuffs" } Anytime you create a new instance of the Stuff class, just update "stuffs". Just note though, that if the instance of the Stuff class goes out of scope, then the stored pointer will be invalid! |
It's good he now has his hair the way it should be. |
What would the world have said if it happened in Africa? ![]() |
Debates don't win elections in Nigeria. Nigerians like you, or they don't like you, that's all. |
@OP Topic should read: "Biased against Nigeria" and not "Biased towards Nigeria" ![]() |
Abagworo:Igbos perhaps? ![]() |
Well at least, if employed, we'll have a foreign coach that will not run away |
^^^ The amount of fusion and fission that will take place in that stomach enh. . . ![]() You no go wan look beans for the next 1 week! |
chidichris:If someone says you should improve, that doesn't make him your enemy. |
^^^ Enjoyment ke? This one na Grenade! |
pappy2000:I think you should be more concerned about her hurting you ![]() |
^^^ All coaches "know" what they are saying until they start the job. |
How this is an issue, I just can't understand. ![]() |
Well, today is Tuesday ![]() |
You did not post the compiler errors? I am not sure there is a var keyword in Java - however, I may be wrong. Looks more like Javascript to me. Try this: char[] specialXters = {'*', '|', '\', ':', '<', '>', '[', ']', '{', '}', '\', ';', '(', ')', '@', '&', '$', '#', '%'}; int numberOfXters = 19; //about 19 characters in this case for(char c: strLine) { int i = 0; while(i < numberOfXters) { if(c == specialXters[i++]) { System.out.println("Characters found" ;break; } } } Insert this into your code. I don't do Java though, but I think should work. If you have any problems tell us the compiler error you're getting as well. |
Now that was a quick reply ![]() Maybe Messi is not the best player in the world, but I doubt if an average player can win FIFA player of the year, or score 47 goals in a season. The last person to do that was Ronaldo in the 90s. You may not like Messi mama-gee, but his statistics are indeed impressive. |
mama-gee:You seem to have two contradictory opinions of Messi, mama-gee. If it is a joke to compare Rooney to Messi, then how can Messi be said to be over-rated? It means Messi is doing something right. . . |
Good. Now people can step in and help. Note: this is probably not valid Java code but your program should look something like this: char[] specialXters = { '*', '%', '&', '/', '\' }; //I don't know if this is what you mean by special characters? while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); foreach(char c in strLine) { int i = 0; while(i < 5) //because I have 5 special characters in this example { if(c == specialXters[i++]) { System.out.println("Special Character found!" ;break; } } } } Essentially, create an array or list to hold your special characters. For each line you read, iterate over the characters in the line to find if the character occurs in your "special character array", if that happens, alert the user that a special character has been found. |
Stranded! |
ABEG, let them check the hand luggage, jor! ![]() |
The complete code? ![]() |
Are those his only conditions? I would have expected him to add: 5. No Interference |
If its 15 million he wants, let the NFF find another person who is ready to deliver and for much less. . . |






