49 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for jsefraijeen

i'm a newbie in java and i got an assignment to do and i don't know how to start ... the problem is: Write a program that will compute for the product of two numbers without using the * operator.. Sample Output: Enter Num1 :___ Enter num2 :___ Product is …

Member Avatar for JamesCherrill
0
9K
Member Avatar for it@61@sec

I have the following struct definition: struct finfo { string filename; long fsize; bool operator() (finfo i, finfo j){return (i.fsize > j.fsize);} } fstruct; And the following vector definition: vector<finfo> fdata; In the code I use the following statement to sort the vector elements by fsize: sort(fdata.begin(),fdata.end(),fstruct); This works perfectly …

Member Avatar for it@61@sec
0
958
Member Avatar for Szabi Zsoldos

Hey guys, Having some difficulties understanding why my OR || operator is not working... First part is BOOLEAN and it is working Second part is STRING and it is working, it returns the desired value What could it be ? <?php if(($oferte->isOrdered($oferte->CleanSapStyleNumbers($oferta->VBELN)) == false) || ($oferte->OfertaValida($oferte->CleanSapStyleNumbers($oferta->VBELN))->valabilitate == "VALABILA")): ?> some …

Member Avatar for minitauros
0
203
Member Avatar for can-mohan

Hi, While executing below code i am getting error like "memory clobbered before allocated block" and due to this assignment is not happening. could you let me know what can be reason for the same. I do understand it is not good to use raw pointer but in current scenario …

Member Avatar for can-mohan
0
443
Member Avatar for Elixir42

Dear Kind DaniWebbers, I am trying to overload the fstream operators (ofstream/ifstream), so that I can save a class to a 'Binary' file and also display it with cout. But the ways in which each need to be implemented is different. Please can you show me how to define different …

Member Avatar for vijayan121
0
4K
Member Avatar for Labdabeta

Hello, I have a particular set up of cast operators and constructors which is leading to a compile-time ambiguity error. I am wondering if somebody can explain why this is happening and what can be done to fix it. For example, here we have 2 classes: class A { int …

Member Avatar for Labdabeta
0
312
Member Avatar for can-mohan

Hi All, I have doubt in my mind regarding declaration of cin and cout object . As per my understanding cin and cout both object are accessible in main then they shouldn't have protected.in below code snippet i have overloaded both input and output operator and while giving new name …

Member Avatar for can-mohan
0
447
Member Avatar for DeadH34d

I've been reading through this introductory book on Python, and I've been following along fairly well. Compared to C++, Python seems to make more sense to me. That is, until I reached a section on Logical Operators. I don't completely understand what I just typed in to IDLE, and the …

Member Avatar for Gribouillis
0
406
Member Avatar for saurabh.mehta.33234

The foll code gives o/p as 2310103 28 Now my doubt is why here 10 is printed two times although i m passing t=6 for the d parameter?? #include <stdio.h> #include <string.h> int f(int a, int b, int c,int d,int e) { printf("%d%d%d%d%d \n",a,b,c,d,e); return a+b+c+d+e; } main() { int …

Member Avatar for Unimportant
-1
244
Member Avatar for Anark10n

Pk, so here's the code I'm running for a checkboxlist object public void regSubjects(object sender, EventArgs e) { int courseCount = 0; for (int i = 0; i < coursesFound.Items.Count; i++) { if (coursesFound.Item[i].Selected) coursesCount++; } if ((courses < 4) && (courses > 6)) clabel.Text = string.Format("Choose between 4 - …

Member Avatar for rubberman
0
322
Member Avatar for rahulinfy

code part1: name1="rahul" name2="rahul" code part2: name1=[1,2,3] name2=[1,2,3] If I run the following code: print name1 is name2 I get "True" for code part1 and I get "False" for code part2 why? why the "reference" is same for name1 and name2 in "code part1" and different for name1 and name2 …

Member Avatar for snippsat
0
212
Member Avatar for tayyabatiq

I'm making a class for boolean expressions, a simpler version of bool. I need three operators, one for AND, one for OR and one for NOT. I can easily make **+** for OR, by overloading, but how can i declare **.** for AND and **'** for NOT? Can i even …

Member Avatar for Nutster
0
260
Member Avatar for darkeclipse8

---------------------------------------------TSet.h------------------------------------------------------ #include <iostream> using namespace std; template <class V> class TSet { public: TSet(); TSet(int size); ~TSet(); void add(V new_item); void remove(V item_to_remove); int num_of_items(); bool isFull(); bool is_item_in_set(V item); friend bool operator==(const TSet<V>& left, const TSet<V>& right); friend bool operator!=(const TSet<V>& left, const TSet<V>& right); friend ostream& operator<<(ostream& outs,const …

0
151
Member Avatar for rahul.ch

I noticed that when equals() is used to compare between two String objects it works fine. But when I compare two StringBuffer objects or two StringBuilder objects or mix of String and Builder and Buffer, equals() doesn't work even though I give same string value to the two objects being …

Member Avatar for rahul.ch
0
318
Member Avatar for 111100/11000

#include <iostream> #include <cmath> #include <string> #include <cstdlib> #include <cstring> using namespace std; char Outputing(char shifted_letter); int found_match; int searching_alphabet; int main() { const char ORIGINAL_alphabet[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; //maybe const isn't necesery char alphabet[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; cout << "This program encrypts messages using Ceaser Cipher\n"; cout << "\n---------------------------------------------------------"; cout << "\n---------------------------------------------------------"; cout << "\nEnter …

Member Avatar for Labdabeta
0
326
Member Avatar for eggsandbacon

Hey everyone, I'm working on an assignment and I'm having some trouble figuring out how to implement two operators. The program creates and implements a class to represent the Stack ADT using a singly-linked list. There is a driver program to test my implementation. I have everything implemented (except the …

Member Avatar for aranayd
1
1K
Member Avatar for wildplace

let say i have an expression like the one below, I guess it goes from left to right? if(exp1 && (exp2 && exp3 || exp4) || exp5)

Member Avatar for wildplace
0
111
Member Avatar for phfilly

Hi -i've started using netbeans and compiling in it recently and I'm not sure what the problem is here. Not sure if it isn't reading the Element.cpp/.h files while building/running the main.cpp In my main: Element a, b(5); cout<<(5+b)<< endl; Then in the .h: Element operator+(const Element&obj); And in the …

Member Avatar for rubberman
0
163
Member Avatar for |-|x

Does anyone know a good way to force javascript to evaluate all operands in a boolean expression? In particular, what I am tring to do is essentially this: return isValid(a) && isValid(b) && isValid(c); while this technically does work, the function is responsible for highlighting invalid areas on the form …

Member Avatar for |-|x
0
427
Member Avatar for Octet

I am attempting to create a script which checks to see if the user has a warning level of less than 3. Basicaly, I want to automatically deny any account which has a Warning Level (stored in the Database) of 3 or more from logging in but whenever I attempt …

Member Avatar for Octet
0
164
Member Avatar for greatman05

Hello. I need to create a program to manipulate polynomials. It contains basic evaluation, addition, subtraction and multiplication of polynomials. Right now, I'm working on overloading the '+' operator to add two polynomials. While the function adds the two polynomials together correctly, when it goes to output through the overloaded …

Member Avatar for greatman05
0
2K
Member Avatar for FelineHazard

Hi all, I am doing some c++ exercise about operator replacing. I have successfully replaced the + (plus) operator to work on a user-defined class. I understand these operators are order-sensitive: need to replace the operator for (class+int) and for (int+class). Thus, creating **two** replacements that do exactly the same. …

0
147
Member Avatar for FelineHazard

Hi guys, I'm learning C++ from a book and I have a question about defining unary operators: In the book I'm working with there's an example, where they define a class called point, and define ++ operator for point *as friend*. here's the example: ~~~ c class point { int …

Member Avatar for FelineHazard
0
212
Member Avatar for kutchbhi

This is the project I am reading from . [url]https://github.com/sasatomislav/PHP5-OOP-Cart[/url] [CODE] class Cart { <snip> private function __construct() {} /** * Fetch Cart instance * * @return Cart */ public function getInstance() { if (NULL === self::$_instance) { self::$_instance = new self; } return self::$_instance; } } <snip> // initialize …

Member Avatar for pritaeas
0
262
Member Avatar for jnewman3

So I have a matrix class that must run on a unix/linux server. The main is a test file that is provided by the instructor. When I compile my code in visual studio it works fine except for test 8 because I can't figure out how to return a print …

Member Avatar for jnewman3
0
1K
Member Avatar for pushpat

Hi folks, I am learning operator overloading concept in c++, wrote sample program to test overloading of unary operator '!' and '-'. Code will work if i use them as friend function but not for member function. Can anybody tell where am i going wrong in function bool operator!(const co_ordi …

Member Avatar for pushpat
0
325
Member Avatar for Labdabeta

I was working on a project when I thought that maybe a ::. operator would look funny in some code. Just for fun I typed that into the global scope area like this: [CODE]::. int main() { //etc...[/CODE] and my code completion software said too many results to display. My …

Member Avatar for Labdabeta
0
190
Member Avatar for Labdabeta

I am really confused as to the purpose of the unary + operator. What in the world does it do? I have tested it and it doesn't return the absolute value. Does it just return the operand? And if so what purpose is it?! (I mainly care about integer types)

Member Avatar for mrnutty
0
296
Member Avatar for Dman01

Hi The following code shows good enough how to multiply two long data [CODE]long x = 10, y = 3; long p = 0; while (y > 0) { if ((y & 01) != 0) p += x; x <<= 1; y >>= 1; } std::cout << "\nResult : " …

Member Avatar for Dman01
0
667
Member Avatar for corby

im trying to overload the operator+= and use that to implement operator+ in my string class. i keep getting a segmentation fault when i try to evaluate something like s1 += s2 where MyString s1("");and MyString s2("hello"); any suggestions as to why this is happening? this is my operator+= function …

Member Avatar for corby
0
179

The End.