gusano79 247 Posting Shark

I get two erros, 'const class Fraction' has no member named 'n' & 'const class Fraction' has no member named 'd'

Well, look at the offending line in Fract.h:

Fraction(const Fraction &src) { set(src.n, src.d); }

Where are n and d defined in Fraction? Nowhere; this is why the error. The other member functions that use n and d get them as arguments, but this construction doesn't have them. I'm sure you want:

Fraction(const Fraction &src) { set(src.num, src.den); }

When I compile it on the command line with g++ -Wall FloatFraction2.cpp Fract7.cpp -o FloatFraction I get more errors than I care to look at.

Start caring; compiler errors and warnings are there for a reason. Read the error message, look at the line it's complaining about, and see if you can figure out why it's a problem. If you're having trouble, post the specific error and we'll try to help.

I copies this code straight from my book (C++ Without Fear 2nd Edition) so I don't understand why it wouldn't work.

By hand? The errors I see look like simple transcription problems:

At Fract7.cpp:111:

return (num == other.num && den == other, den);

Looks like you typed , where you meant .; it should be:

return (num == other.num && den == other.den);

Same thing at Fract7.cpp:106:

return Fraction(num * other, num, den * other.den);
gusano79 247 Posting Shark

So I'd have a table that has an employee, the job he is at, a date, and the hours they worked that day

Yep.

That looks fine, but I would use employee number/id, rather than his/her name.

Also yep. Make that a FK back to the employee table.

It seem a little weird to me to have so many rows being created with the same Employee and Job columns but I can't think of any other way to store them in a database.

I can't think of anything simpler/cleaner either. This is fine; data models can often look strange coming from a more conceptual perspective.

And I know my project isnt that big but for huge projects with a method similar to this it looks like it could be creating an insanely huge number of rows every day.

It certainly could... but you're going to need this data one way or another, so step one is to do something. I think we've ended up at a good place for your smaller project. I wouldn't worry about scale unless you actually notice a storage or performance problem, and in the latter case, make sure you profile/measure the problem area to make sure you know exactly what's slowing things down before you make any changes.

I think we've left it at a good place for now. The data model is reasonably simple and understandable, and it gives you some flexibility in how you build …

gusano79 247 Posting Shark

I'm looking for what exactly is a Vector3 (or any Vector for that matter) and also what a Quaternion is in code? What are the variables types? Should you have multiple classes for each type?

Depends on the language you're using, and even then, there are multiple ways to represent vectors and quaternions.

Vectors in R3 can be simple structures with x, y, and z members, or you can use an array-like member to hold those values instead. You'll need arrays (or equivalent) to represent generic vectors in Rn though. If you're going to be working with matrices, you might also consider using a 1xn or nx1 matrix for your vectors.

The actual member type will be something "close enough" to a real number. For practical purposes, this is usually a single- or double-precision floating point value, unless you're doing something special, which is an entirely different conversation.

Then there are vector operations--some are only defined for vectors of certain sizes, and others, while they can be written generically for any size vector, have alternate implementations that are smaller and/or faster for certain sizes. Depending on your language, you may be able to take advantage of inheritance and/or templates to avoid writing duplicate code.

The quaternions (denoted H) are equivalent to vectors in R4, just with special operations.

gusano79 247 Posting Shark

We won't write it for you - show us what you've done so far, and it helps to indicate a specific question or problem you're having.

gusano79 247 Posting Shark

read a list of arithmetic expressions from given file...

zaheen: post separately and show some work.

gusano79 247 Posting Shark

I was thinking about having an employee table, a job table, and then a employee_job table that has a foreign key to an employee and a job.

This is a pretty standard way of doing a many-to-many relationship in a relational database; it should work for you.

In the employee_job table there would be a one to many link with a weeks table which would just hold how many hours the employee worked that week for that specific job.

I'm wary of representing weeks directly in the data; it feels too constrained. Depending on your requirements, doing it by week may be just fine, but in general, I'd suggest relating hours to a specific date. This allows you to chop the data more freely (e.g., start the week on Sunday vs. Monday in some cases), and frees you from having a custom definition of "week" (makes your system harder to maintain).

gusano79 247 Posting Shark

Do you have a question?

gusano79 247 Posting Shark

Start with the two circles which contain the arcs. Where do they intersect? If they do, then see if the point(s) is(are) on one of the arcs.

gusano79 247 Posting Shark

make it shared across my LAN with others so that they can pull a copy on their own PC and work on it, and push their changes to the project, and thus make it available to all devs concerned.

You want some sort of version control system to avoid the special hell that is conflicting edits.

What is the best way/tool available to share such a project freely on a LAN?

There are more than a few systems out there, depending on your requirements...

What tools would be required for each user to get access to be able to pull/push a copy from their PC using VS 2015?

Off the top of my head, Visual Studio integrates with Git and Subversion; there are also VS plugins for other source control systems.

Ritesh_4 commented: thanks will have a look at these options +6
gusano79 247 Posting Shark

The only downside is that it appears to require some compiled binaries. I understand that it might not be possible to get around this though...

The only dependencies are whatever system libraries are necessary on your platform, and GLFW builds very easily from source. You can use CMake to create project files, but it's simple enough to do it manually; this is what I have done for my personal projects that use it.

OpenGL without the useless Win32 baggage

A little "gotcha" here... there are a few things that some (most?) Windows-based systems need for gl.h (e.g., having APIENTRY defined). I recommend including glfw3.h wherever you need OpenGL, even if you're only making GL calls; it takes care of the necessary bits without the overhead of including <windows.h>.

gusano79 247 Posting Shark

If you want to be cross-platform, GLFW is an excellent lightweight library that handles creating OpenGL contexts, basic window management, and user input. Then it gets out of your way.

gusano79 247 Posting Shark

First things first...

How is this even compiling? You use the name res which isn't defined anywhere; I assume you mean result.

I have some segmentation faults, can't find what is wrong

What compiler are you using? Does it report any warnings? It should.

VS2015 gives me:

main.c(78): warning C4700: uninitialized local variable 'n' used
main.c(81): warning C4700: uninitialized local variable 'array' used
main.c(83): warning C4700: uninitialized local variable 'result' used

array and result are pointers, but you never actually point them at anything, so they're pointing who knows where and that's why the segfaults. Create some MATRIX objects and use those.

could you show (in the code) how to add 'n' matrices?

First thing I'd do is refactor a little bit - make these things separate in your code:

  • Creating new MATRIX objects
  • Deleting them
  • Reading them in
  • Adding them

This will make the problem easier to approach; your code is a bit of a mess right now.

For the addition portion, start by considering addition of simple integers. How would you do that? Here's a suggestion to start with:

int Add(int *values, int numValues)
{
    // ...
}

If you can do that, then all you have to do is change int to MATRIX and figure out how to add two matrices, not n.

gusano79 247 Posting Shark

Same as you'd add n numbers: Initialize a "sum" matrix to all zeros, then add matrices 1..n to the sum.

gusano79 247 Posting Shark

Yes, I am using GLEW for my opengl functions.

Aha. See if this SO answer gets you going.

gusano79 247 Posting Shark

Hm. Perhaps an overzealous browser pre-loaded it for you from a link on a page you visited?

gusano79 247 Posting Shark

The file you're trying to load is UTF-8 encoded. Try using UTF8Encoding instead.

gusano79 247 Posting Shark

Please format code, something like this:

int main()
{
    int number[20];

    for(int i = 0; i < 20; i++)
    {
        cout << "enter a number up to 20" << endl;
        cin >> number[i];
    }
}

what to do after this?

I imagine you should...

sort them ascendingly using arrays.

So you have numbers in an array, number.

If this is an assignment, you shouldn't be completely unprepared; your instructor should have introduced you to at least one sorting algorithm before giving you this task.

Do you truly have no idea how to sort them? If not, that's okay--I'm just trying to figure out the best place to start.

gusano79 247 Posting Shark
gusano79 247 Posting Shark

We don't do assignments for you. Show us your work so far, tell us what you're having trouble with, and then we'll be able to help.

gusano79 247 Posting Shark

What do you have for WriteMemoryCallback?

It should at least start like this:

size_t WriteMemoryCallback(char *ptr, size_t size, size_t nmemb, void *userdata)

Everything you need to know is here:

gusano79 247 Posting Shark

Show us what you've tried so far, tell us what you're having trouble with, and then we can help.

gusano79 247 Posting Shark

Show your work so far, tell us what you're having trouble with, and then we can start to help.

gusano79 247 Posting Shark

Show your work so far, tell us what you're having trouble with, and then we can start to help.

gusano79 247 Posting Shark

You can't tell from return value from atoi alone. If it returns 0, it's easy enough to check if the string itself is actually "0" (i.e., '0' followed by '\0').

gusano79 247 Posting Shark

Are you looking for a digit in the first position here? Because if you are, the characters '0' through '9' don't have values 0 through 9.

gusano79 247 Posting Shark

I meant the username being logged, not the logged-in user; sorry for the confusion.

Does the audit trail's user name match the app pool identity?

gusano79 247 Posting Shark

Is the user name being logged the ASP.NET application's IIS app pool identity?

gusano79 247 Posting Shark

Another approach:

  1. Shuffle your list of questions (make a copy if the original order is important)
  2. Present them in the new order
gusano79 247 Posting Shark

You can't get a non-member pointer to a member function. If you did, and called it, what would the function use for this?

gusano79 247 Posting Shark

What I'm looking for is a library that can read in an equation...

Well, if your input is like the example (V = Q/C = ...), you can split at = and proceed with shunting-yard as you said, at least for this portion.

parse the relations between the variables and can reverse the relationships so if I give it any set of all-but-one known values, it can calculate the unknown variable.

Hm. Something like MATLAB?

gusano79 247 Posting Shark

You mean like the first paragraph of https://en.wikipedia.org/wiki/Database_index ?

gusano79 247 Posting Shark

All too often, sadly. My two most recent experiences went like this:

  1. Notice awful code, realize it's so tangled that it's impossible to work on it bit by bit, convince everyone it's not worth "fixing", replace it completely

  2. Notice awful code, carve off bits that are fairly self-contained and rework them, repeat until it's good enough or you retire.

It's a bit like copyediting the Necronomicon...

gusano79 247 Posting Shark

define "equations".

I second the question; are you looking for an algebraic solver, like a system of equations kind of scenario?

What do you see as an equation?
1 + 3 + 4 - 1 / 2 = ?
or
"1 + 3 + 4 - 1 / 2 = " ?

Those are expressions, "equals" sign notwithstanding. Or is the "?" in the first example meant to be a variable name?

gusano79 247 Posting Shark

This right here is your problem:

*ptr = '\0'

...because you do this earlier:

ptr = string

...which means you're modifying the string as you scan it. This is not a good idea.

A better signature for your splitter function would be:

int StrTok(vector<string> &vTokens, const char* string, const char *delim);

Note the use of const; now the compiler won't let you change those arguments.

This breaks your code, though, so you'll have to work out how to split the string without modifying it. You could make a copy, but I think a better approach would be to track the start and end positions of the "current" token, advancing them as you find the delimiter string.

Unrelated comments:
* ptr doesn't need to be static.
* i should be a size_t to avoid the signed/unsigned mismatch warning.
* p_str isn't used anywhere.

gusano79 247 Posting Shark

Sounds like a homework assignment; we won't do it for you.

If you don't know where to start, you might try Ralf Brown's Interrupt List.

gusano79 247 Posting Shark

What other headers are you using? One of them must be including cctype for its own purposes.

gusano79 247 Posting Shark

Do you have a complete example that's short enough to post?

You may be able to use some sort of RAII-like approach; i.e., release the handle in some object's destructor. But beware std::exit... nothing with automatic storage duration will have its destructor called. std::atexit should help there.

If possible, I'd avoid "exit" and just set a flag instead:

bool running = true;
do
{
    Sleep(10);
    if (kbhit())
    {
        running = false;
    }
}
while (running)
// Cleanup
gusano79 247 Posting Shark

Would you temporarily allow for the fact that both algorithims could be used in the code, or do you create a program that makes the necessary conversions, and uploads the data to another server, or what?

Either could work, and I've seen both done... If you can, I'd go with a one-time conversion. You have the passwords encrypted, so there's no technical reason you can't just decrypt and hash them all at once. Just make sure that this change happens at the same time you deploy the application with the change to hashing.

Also, what Hash algorithims are generally considered secure for this kind of thing.

https://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions

One of the more recent SHA algos would be a decent choice; they're supported by the .NET framework

I know that the higher the number after the algorithim, generally the better secured it is, because it "rotates" or morphs the data that many times

For older ones maybe, but for more recent hashes, the number is often the length of the hash itself.

overwraith commented: Thanks for the reply. +2
gusano79 247 Posting Shark

I was able to compile this without changes using VS2013... what are you using?

kumanutiw commented: thax its now working ...... +0
gusano79 247 Posting Shark

I'm sure someone here can help if you give us details. What's the project, what are you having trouble with, and what have you tried so far?

gusano79 247 Posting Shark

Here's your main problem:

if( to_string(i).compare(s) == 0){

string::compare looks for an exact match, which only happens when i is 666.

But you're ignoring the first time the match happens, so your code as written will happily spin on forever, looking for a nonexistent other 666 to show up.

If you want to reproduce Java's String.contains, you should use string::find instead.

Another observation:

cout << i;

This, unlike System.out.println, won't write a newline for you. Have a look at std::endl.

gusano79 247 Posting Shark

Have you actually profiled the code? It wasn't clear from your post, nor from your response.

I thought this "Not what I am after, but what I stated is the bottle-neck anyway" was an obvious yes ;)

Just making sure... it sounded like you probably had, but experience has taught me to verify in the absence of an explicit statement, especially regarding performance. I've encountered too many people who "know" what the problem is and don't see the point of actually measuring anything.

I'll leave it alone, but I notice you still haven't given an explicit "yes" :)

You end up with one query for each nesting level.

EF does it in one query, wondering how to replicate that.

Everything I can think of offhand ends up with a giant denormalized result, which could get unwieldy if there's a lot of nesting and a lot of data.

You could set up a simple object hierarchy and use a database profiler to see what EF comes up with.

gusano79 247 Posting Shark

Does the loading really need to be more efficient?

Yes, it does.

Where in code is that time being spent?

As stated, in getting the child objects recursively one-by-one.

Performance profiling will give you much better information

Not what I am after, but what I stated is the bottle-neck anyway.

Have you actually profiled the code? It wasn't clear from your post, nor from your response.

I don't mean to pick at this; profiling is something everyone who has a performance problem should do, even if it's only to confirm what they already know about the code: nothing beats cold, hard evidence to justify spending time (== money) on this kind of improvement.

If you haven't, it might be worthwhile... I've seen some abysmally-performing .NET data access code that spent 95% of its time buried deep in the internals of DataReader digging up table metadata to determine column types, rather than on the query itself.

lazy loading is a decent option

I know, but I need all data in this case so it will only move the delay down the line.

Fair enough.

Reuse the database connection for multiple queries

Already in place.

Yay!

Combine sub-queries for multiple objects

How would I do that with deep nested child objects?

You end up with one query for each nesting level. In SQL, it ends up looking something like this:

SELECT …
gusano79 247 Posting Shark

Question one is always: Does the loading really need to be more efficient? In other words, is there a measurable and significant wait/delay when you're loading things? If not, or if the delay is acceptably short, I wouldn't worry about it.

If there's a significant/unacceptable delay, then question two is: Where in code is that time being spent? Use a performance profiler; the results may be surprising (anecdotal evidence available if you want).

If profiling indicates the queries themselves, question three is: Do you need the data all at once, or are you using it piece by piece?

If you're using the data piece by piece, lazy loading is a decent option; it spreads the loading cost over time, and it will be far outweighed by the time spent doing whatever it is you do with the data. Also, this will avoid loading data that you don't actually use, if any.

If you need all of the data together, then it really comes down to the overhead of making the queries. Performance profiling will give you much better information, but off the top of my head, I can think of two things to do:

  1. Reuse the database connection for multiple queries
  2. Combine sub-queries for multiple objects
gusano79 247 Posting Shark

I don't understand the memory part I got confused

It says that memory at 0x00600000 through however long the assembled code is contains the program, and everywhere else (i.e., 0x00000000-0x005FFFFF and the end of the program to 0xFFFFFFFF) has the value -1.

gusano79 247 Posting Shark

With generics, you can use type parameter constraints to limit the types someone can use with a method, to a certain extent.

If I'm reading you right, though, that's not what you want. The point of a generic method is that the code is identical, no matter what type you put in the parameter. If you find yourself making decisions based on what the actual type is, then you're probably misusing generics.

In this specific case, I think what you're really looking for is a pair of methods, perhaps like this:

public static SqlDataReader ExecuteSelectProcedureSqlDataReader (string procedureName);
public static DataTable ExecuteSelectProcedureDataTable(string procedureName);

To preserve the kind of reuse you're attempting, you can have ExecuteSelectProcedureDataTable call ExecuteSelectProcedureSqlDataReader internally.

ddanbe commented: Great! +15
gusano79 247 Posting Shark

You're writing a class that implements an interface:

public class EWrapperImpl : EWrapper

This means your EWrapperImpl class must have methods that match everything in EWrapper...

Error: TestCsharp.EWrapperImpl' does not implement interface member 'IBApi.EWrapper.currentTime(long)

...but it doesn't, so...

you need to provide at least an empty shell of the method declared in EWrapper but I don't know how to do this. I wonder if it is a basic delaration that can be done in EWrapper ?

Implementing an interface is a way of saying, "My class has these methods."

EWrapperImpl needs to have a method called currentTime that matches the declaration in EWrapper; i.e., it has the same parameter and return types.

tobyITguy commented: supported. +3
gusano79 247 Posting Shark

am just wondering would it be possible to convert the server side to a windows based system?

Maybe. depends on if you used any OS-specific libraries. The networking code is most at risk, I think.

would it be possible to say change the code to a newer visual c++ IDE

Almost certainly. I'd definitely go for VS community edition, since it's free and all. Or if you want to avoid MS products, there's Code::Blocks or Cygwin+GCC,

gusano79 247 Posting Shark

doesn't work in a proper way. It execute with errors.

What are you expecting it to do, and what is it actually doing? What are the errors?

gusano79 247 Posting Shark