Eagletalon 34 Junior Poster in Training

Anything declared Private can only be accessed by the class itself but anything declared Public can be accessed by any class referencing it...

Think of it like a computer on a network... only your computer can access all the folders... but all computers can access the folders you mark as "shared"

Eagletalon 34 Junior Poster in Training

http://www.daniweb.com/software-development/c/threads/114052

Follow that link and lets see if you can find the answer yourself...

This isn't really an error and wont kill your program... so lets see if you can get it... :P

work for your major ;) :D... best of luck buddy

Eagletalon 34 Junior Poster in Training

My apologies I also made a mistake... should be if(issquare())... typo on my side

Keep it as Rectangle::isSquare()... just make it a bool and give it a try

Eagletalon 34 Junior Poster in Training

Alright you have 2 errors there... I think keep it as it is (in PrintInfo()) but remove the text "Rectangle."... so it looks like:

void Rectangle::printInfo()
{
	cout << "the length is " << length << endl << "the width is " << width << endl;
	cout << "the perimeter is " << perimeter << endl << "the area is " << area << endl;
 
	if(isSquare)
		cout << "the rectangle is square" << endl;
	else 
		cout << "The rectangle is not a square " << endl;
 
}

then we check the other error if it is still there

Eagletalon 34 Junior Poster in Training

Which if gives you the problem?

Also on the function data types... something like "calculate perimeter" I would make a void function... but then you dont have a line in that function with "return"... you just leave it out...

In the case of "IsSquare()" I would make it a bool and use it in a way like:

if (object1.IsSquare(){

    cout << "Object 1 is a square" << endl;
}

then the return would be a true/false ofcourse

Eagletalon 34 Junior Poster in Training

Yeah as I said... a function declared "void"... (eg. void Rectangle::isSquare()) can not have a "return"... just take out those lines and the errors should cease

Eagletalon 34 Junior Poster in Training
void Rectangle::calculatePerimeter()
{
	(length * 2) + (width * 2) = perimeter;
		return perimeter;
}

The errors in the code above show up as are right next to the first "(" brace and it says "expression must be a modifiable value" Second one is on my " return perimeter" and it says " Return value type does not match function type"

alright here I can see 2 things that are troubling me... 1st place a function declared as "void" can not have a return type... so if you take that away the error should disappear...

And secondly: "(length * 2) + (width * 2) = perimeter;" should this not be -> "perimeter = (length * 2) + (width * 2);"? as you assign the value?

void Rectangle::calculateArea()
{
	length * width = area;
		return area;
}

on "length" it says "expression must be a modifiable value" and the other one is under "return area" and it says "return value type does not match function type"

Again the same 2 problems

void Rectangle::isSquare()
{
	return fabs(length - width) < .0001;
}

under "fabs" it says "return value does not match the function type"

and again with the return in the "void" function...

also when working with a return, I make it my standard practice to always return a already set variable rather than a calculation... easier to debug and find problems... but thats just me

so no real big problems just a bit of a syntax …

Eagletalon 34 Junior Poster in Training

Put a timestamp in the table that you update and select based on that?

Eagletalon 34 Junior Poster in Training

Alright mate, first thing is first... bloody well done on getting this far by yourself, unlike many others that use this forum you actually tried and deserve recognition for that fact...

now what are you having troubles with? do you have compiling errors or are you having incorrect or not anticipated output? or do you not know where to go or what seems to be the problem here?

Eagletalon 34 Junior Poster in Training

now just apply the same logic to the bytes conversion to megabytes and you should be set :D best of luck to ya mate :)

Eagletalon 34 Junior Poster in Training

Alright... so if I say there is 1000 milliseconds in a second... then would you agree you can fit 500 milliseconds into 1 second twice? so it would look like the following:

x = 500 (ms)
y = 1000 (ms in a second)
z = y/x
z = 2...

so if you have for example 4000 bytes each 500 ms... then you would get 8000 bytes in a second... do you agree?

Eagletalon 34 Junior Poster in Training

It sounds like you built the hard part already? how can the calculation beat you down?

did you give it a try? can you give an example and we will show you the spots we think you can improve...

Basic questions to look at for this type of calculation:

1. Amount of milliseconds in a second
2. Amount of bytes in a Megabyte
3. Build calculation to convert your bytes -> megabytes... you milliseconds -> seconds and run the same calculations vs your input... (should all be multiplication and division)

Eagletalon 34 Junior Poster in Training

One thought for it.
Make an array of strings like strArrayStringNumber[10];
Which will have value {"zero","one", "two", "three", ..upto..."ten"}
Then taking one digit at a time, pass it into array like if number is 213
take 2 first and call strArrayStringNumber[2], it will give corresponding string.
So on for rest of the string.

I like this approach, would work well for each digit individually... but how would you implement it to return for example "four-hundred-seventy-five"?

Eagletalon 34 Junior Poster in Training

Well getting a specified range would be nice... but my general thought would be something in the line of:

-Check the length of the integer provided (amount of chars)...
-Write a comparison in to resolve each amount (eg. 3 chars would resolve to "hundred")
-Check the very first digit
-Write a comparison to resolve the first digit (eg. "2" would resolve to "two")
-Add in additional comparisons for each value with a special naming (eg. "eleven", "twenty" etc.)
-Run input through a loop removing one digit at a time and running the result through the same checks again

there might be an easier way, and the larger range you wish to include the more checks you need to enter...

but I believe its easy to understand and code even for a beginner...

Eagletalon 34 Junior Poster in Training

Uhm... I dont want to sound like an ass but that is not really helping... we told him to at least try... everyone on this forum will help some-one if they at least try themselves... be it error handling or code correction... but giving them results is just strengthening their lack of knowledge

Fbody commented: Well said. +13
Eagletalon 34 Junior Poster in Training

It means that there is a possibility that an condition or a loop statement flow results in a path without a return value

i.e. function runs and is expected to return a value but there is a possibility that it wont and thus create an application error...

all the compiler is telling you is to clean up and ensure you ALWAYS have a return :)

If you dont need any data returned... try declaring the function as a "void" or simply returning a 0 (numeric types), ""(text types), true(bool) etc

Eagletalon 34 Junior Poster in Training

Get a input of each 1... and calculate the values and total? Come on mate give it a try at least... don't ask people to do your project for you?

Eagletalon 34 Junior Poster in Training

.round?

Eagletalon 34 Junior Poster in Training

I'll help you with the tri-angle... but you need to apply the logic and put them together to build the diamond...

{

		// Make triangle shaped like so(- stands for blank space)
		// ----*
		// ---**
		// --***
		// -****
		// *****
		int rowSize3;
		
		cout << "Please enter another row size for a different triangular shape: ";
		
		cin >> rowSize3;

		for (int r = 1; r <= rowSize3; r++){ // Number of lines to display

			for (int c = 0; c < (rowSize3 - r); c++){

				cout << " ";
			}
			for (int c = 0; c < r; ++c){

				cout << "*";
			}
			cout << endl;
		}
	}
Eagletalon 34 Junior Poster in Training

Allright guys... due to a deadline and other external factors Ive not been able to test any of this or investigate further

Simply had to write a VB satelite, will maby check back to this when the oppertunity arises, for now I am just going to mark the thread solved to save everyboddy's time, thankyou very much for the quick responses :)

Eagletalon 34 Junior Poster in Training

Hi There,

I hope somebody can help me, I work with Visual C++ 2008 with QT libraries

I am trying to include a Interop.Encore.dll file into my program to access our ERP system business objects and post new data to the ERP

We have a Visual Basic program geared to communicate with our ERP using this same DLL file...

Now what is the Syntax for including the neccesary DLL file (no header file available) into my program?

I will also add that I have built my program using a qmake command (compiles headers and source files etc into a sollution file) to include the dll and when I build the solution I get the following:

"1>fatal error C1308: c:\...\Libs\Interop.Encore.dll: linking assemblies is not supported
1>LINK : fatal error LNK1257: code generation failed"

Eagletalon 34 Junior Poster in Training

That's because your regional settings is US or any other that has MM/DD/YYYY.
If I where to run it I would get the same error (I'm Greek = DD/MM/YYYY).

Wow... there I learned something awesome :D... thnx man... oh and btw I'm from South Africa and I believe the setting fall under UK? :S nevertheless if that solves it then bloody well done, wouldn't have thought of it in years

Eagletalon 34 Junior Poster in Training

It runs perfectly for me?

QUERY:

SELECT DATENAME(MONTH, CONVERT(DATETIME, '5/28/2011')) AS ReceivedMonth

RESULTS:

May
Eagletalon 34 Junior Poster in Training

Hi jovillanuev

Error:
Msg 241, Level 16, State 1, Line 2
Conversion failed when converting datetime from character string.

This error is 1 I've had many times over... it means that the string you are using for a date is not in a valid format for SQL to interpret...

Could be something like: "201121 14:35"...

would it be possible to just select the string to see the output? give us an example of what needs to be converted

Eagletalon 34 Junior Poster in Training

Hi there everyone,

I really hope someone can help me, I am working with Visual C++ with QT libraries and using... well... something that represents MVC (long story)... now I need to pass a const QString& from my 1 controller class to the model of another class...

When doing so I get an access violation app crash... I have checked the variable to be passed just before the function call and also entered a message to be displayed first thing in the function being called... the value is available and displays 100%, but before the next debug message shows the app crashes... Anyone with any advice as to why this could happen or how to fix it?


Sending:

if(NoFaultFound){

		qDebug() << "Executes" << endl;
		system("pause");

		for(int k = 0; k < ResourceNumbersToUpdateList.count(); k++){

			qDebug() << "Value check: " << ResourceNumbersToUpdateList.at(k) << endl;
			system("pause");

			ResourceTWObject->DataObject->updateOperation(ResourceNumbersToUpdateList.at(k));

			qDebug() << "Does not reach" << endl;
			system("pause");
		}
	}

Receiving:

void ResourceContainerCLS::updateOperation(const QString& ResourceCode){

	qDebug() << "does not execute" << endl;
	system("pause");
Eagletalon 34 Junior Poster in Training

In this case I would not use "Person* person" in the Model,

I would have a Controller class,

which will be instantiated as an object in your View class (Person)

the Controller class will have an object for the Model class (PersonDB)...

and you will work with a middle method to call the functionality of the Model, Or you can even try something like the following in the view itself:

void Person::saveData(){

    <ControllerName>.PersonDB.AddpersonTodb(Person name)
}

If I try to explain it... the Controller communicates the program functionality (in the Model) with the user input handled in the View

Eagletalon 34 Junior Poster in Training

Basic program coming up... please forgive the datatypes, I work mainly with QT libraries

MODEL:

QTreeWidgetItem ContainerClass::loadData(){

    <Database call and query>

    QTreeWidgetItem item.text(<field index> = query.record.value(<fieldname>).toString().trimmed();

    return item;

}

VIEW:

void ViewClass::on_btnLoad_clicked(){

    ControllerObject * TWControlObject = new ControllerObject()

    TWControlObject->loadData();
    
}

Controller:

void ControllerObject::loadData(){

    ContainerClass * DataObject = new ContainerClass();

    tw->addTopLevelItem(DataObject->loadData());

}
Eagletalon 34 Junior Poster in Training

Try the following?:

SELECT ItemNumber,	
             PurchasePrice,
             ReceivingPO,
             DATENAME(MONTH,CONVERT(DATETIME, ReceivedDate)) AS ReceivedMonth
FROM #VPTable as vp
WHERE vp.ReceivingPO IS NOT NULL
adam_k commented: I stand corrected +7
Eagletalon 34 Junior Poster in Training

Perhaps try something simple like a Message Box or console message after each line where there is a possible error, with a pause right after it, then you can see the flow progress slowly (step by step) and check where the problem arises...

Eagletalon 34 Junior Poster in Training

I Still dont understand what the problem is? what are you attempting to do and what is different / incorrect to the desired output?

Eagletalon 34 Junior Poster in Training

Could you possibly provide some example data? perhaps the record that "breaks" the insert? (you mentioned the first 6 works, perhaps nr 7 is a problem?)

Eagletalon 34 Junior Poster in Training

is it possible the data contains characters that would "break" the insert? eg. a VARCHAR value like: 'Stan's bbq'

Eagletalon 34 Junior Poster in Training

1 Question... how does 1 do this for a column with the data type char if you want tot take it to decimal... gives me an error on the conversion....

"Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric."

is there an additional way to write in a CONVERT for the data included in the field?