Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yea -- like this quote from The Myths of Islam

the Quran not only calls Muslims to submit to Allah, it also commands them to subdue people of other religions until they are in a full state of submission to Islamic rule.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

inline functions can't be declared in a *.cpp file and expect it to be inlined in other *.cpp files. Put the entire code in the file.h header file so that the compiler can duplicate the code each time the function is called. This is consistent with the use of _inline for c++ class methods, where you write the entire function in the header file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Knowing how to use google is a must for any programmer, new or old. If you have a question and can't find the answer in a textbook you may have, or if you don't have a textbook, then the first source of information should be google. For example the previous poster asked about Visual Studio and android. His answer could have easily been found by just typing "visual studio for android apps" in the google text box, like this.

old_apache commented: as programmer, google is my best friend :D +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

don't worry, there will be no Christians and Jews left in Syria after the Islamists win

Islam, the religion of peace.

<M/> commented: Yep, that right :D +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

mysql has an export utility program (mysqldump.exe).

mssql has an import utility program.

No need to write a program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is an example I worked up,

Imports Microsoft.Office.Interop

Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles Button1.Click
        Dim oExcel As Object = CreateObject("Excel.Application")
        Dim oBook As Object = oExcel.Workbooks.Open("c:/Book1.xlsx")
        Dim oSheet As Object = oBook.Worksheets(1)          
        Dim i As Integer
        Dim cell As String
        For i = 0 To 10
            'set cell name, e.g. A1, A2, etc
            cell = "A" & Convert.ToString(i + 1)
            ' get cell data from Excel
            cell = oSheet.Range(cell).Value
            ' add the data to Listbox1
            ListBox1.Items.Add(cell)
        Next
        oExcel.Quit()

    End Sub

End Class
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Once you know how to extract column A from the excel sheet it should be a simple matter to insert the values into a listbox.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

more i hate C++:(

It's a learning curve that's getting you. Stick in there and you'll get it all figured out, it just takes some time and practice.

but the static functions don't accept the normal variables

Yes, that's by design. How can a static function know the value of an instance variable? If there are 10 instances which one should it use?

and don't use properties

What do you think class objects are? In the example you posted strnome is a property of Pessoa2 class.

and events(only Visual Studio, but isn't portable:()

events are not part of the c++ language but rather an extension of the c++ language much like any other library. You get similar events with other compilers such as Borland, QT, and libraries such as wxWidgets. Don't confuse the language which is defined by c++ ISO standards committee with what is in libraries which anyone can write.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Actually, I was using that in about 1958, or more than 50 years ago :) It was the first typewriter I ever used.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why did you declare nome inside the if statement?

I think you have the variables mixed up. strnome is a member of Pessoa2 class. You need to pay closer attention to what is and is not class members.

static void setNome(string nome)
    {

        strnome = nome;
        if(strnome.length() == 0) 
           strnome="ana";
        showname();

    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

vb.net is not difficult to learn -- Here is a good free tutorial

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you really expect me to remember a password from 30 years ago :)

<M/> commented: LOL +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here's an interesting little article I cam across recently.

Walk into any bookstore, and you'll see how to Teach Yourself Java in 7 Days alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. ... The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days. Felleisen et al. give a nod to this trend in their book How to Design Programs, when they say "Bad programming is easy. Idiots can learn it in 21 days, even if they are dummies.

The article also has a lot of good advice for new programmers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use clock() instead of time(). clock() returns the number of (usually) milliseconds that have elapsed since the program started. I don't know how changing the computer's time will affect clock()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

inline functions, the compiler can choose to make them inline as if they had been macros or to just make them regular functions. inline functions as well as functions written as macros has the potential to bloat the compiled program, making it a lot larger than if the function had been written as normal functions. With macros the compiler has no options but to duplicate the code every time it is called. But if you use inline functions the compiler can elect to make them normal functions in order to reduce program size.

Here are a few guidelines I follow:

  1. never write functions as macros, IMO that is just bad programming style.
  2. One or two statement functions should be written as inline functions.
  3. Any functions larger than two statements should be normal functions.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I will go with my method because it has less no. of statements

That's a poor reason not to use his code. If you post the exact assignment I'm willing to wager that your instructor wants you to swap the variables in memory, not just on the console screen.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
if (x == 0) then  // O(1) simple variable access
      for i = 1 to n do // O(n)
           a[i] = i; // O(1) simple variable access

Now, read this again until you understand it

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A 2d array is declared like this:

int values[10][20];

It is very similar concept to an Excel spreadsheet, which has columns and rows. In the above declaration the array has 10 rows and 20 columns. What phorce illustrated above is a 1d array, not a 2d array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We can help you if you would tell us what you don't understand about 2d arrays.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

clock() returns milliseconds, time() returns seconds. If it's bubble sort then just to the bubble sort once instead of a million times as in my previous post. But you will have to give it a pretty large array so that the time is measurable. If the entire time to do the bubble sort is less than 1 millisecond then the measurable time will be 0.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You'd have to get a hook into the clock cycles of your computer

That would be going a bit to the extreme -- just using standard C function clock() and repeating the algorithm a million times would probably be sufficient.

clock_t t1,t2;

t1 = clock(); // get starting time
for(int i = 0; i < 1000000; i++)
{
    // do algorithm here
}
t2 = clock(); // get ending time

int diff = t2-t1;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

They both do the same thing -- its just how the object is declared. The -> is pointer notation. Some examples:

class MyClass
{
public:
   int x;
 };

 // in this function pMyClass is a pointer, so it requires -> to 
 // reference any of it's objects
 void foo(MyClass* pMyClass)
 {
     pMyClass->x = 0;
 }   

 // in this function pMyClass is a reference which uses the . notation
 void foo(MyClass& pMyClass)
 {
     pMyClass.x = 0;
 }


 int main()
 {
    MyClass mc;
    mc.x = 0; // Neither a pointer nor a reference

    MyClass* pmc = &mc;
    pmc->x = 0; // This is a pointer and requires -> notation

    MyClass& rmd = mc;
    rmc.x = 0; // This is a reference so it requires . notation
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Libitarian is a political party that has been around in the USA for many many years.

The only difference between Conservatives and Libertarians is that most Libertarians advocate the legalization of drugs.

http://answers.yahoo.com/question/index?qid=20080203090809AA1hWDT

LastMitch commented: Thanks for the link! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can you change it to something that isn't your name and then back to your name?

I don't think so -- as I recall we only get one crack at changing the user name.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends. When a function returns a c++ class it will return a copy of the object, not the object iteself, so it doesn't matter if the original object is on the heap or the stack. If the function returns a POD array, such as char array then it must be declared in the heap because the array is not copied. When such an array is declared on the stack then the array is destroyed as soon as the function returns, making the array invalid. That is the cause of many difficult to find bugs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
<M/> commented: lol +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are no profits to be made by nuking Syria.

That sounds a bit like Quark from Star Trek :P)
1fdd06eb1222b335164a599b5dcee166

Reverend Jim commented: Hah +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If US does not get involved, things are going to get ugly.

Put your money where your mouth is -- join the Marines and be the first to go over there to put your life on the line. What makes you think it is US responsibility to resolve their problems? Hell, we can't even resolve our own problems.

pritaeas commented: Well said. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

us should not take any military action, that's what united nations for.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to disable all those things in the BIOS -- when the notebook starts to boot press F2 or Del key before Windows starts.

I downgraded my PC a couple weeks ago, all I had to change in the BIOS was disable Secure Boot, and I'm not sure that was even necessary. Windows 7 installed without a problem. I read somewhere on Microsoft site that you can downgrade to Windows 7 and use the same key that you used for Windows 8, but of course you will need a Windows 7 installation disk to do that, and the only way to get the install disk is to buy it, unless you already own it. When you downgrade you will have to reformat the hard drive, so make sure you back up all important files before you start.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Line 12 of Form2 does not make the datagrid public -- it makes a function public. You need to find the line in Form2.h that declares datagridview1 and change it from Private to Public. It should be a line that looks like this:

public: System::Windows::Forms::DataGridView^ dataGridView1;

ddanbe commented: For the effort :) +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Normlly you would not want to do that. But you could just make the grid Public in the class header file.

manel1989 commented: 555555 +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

43 years ago! Hummmm -- was Dani even born yet? I knew Dani was good -- but didn't know she was that good :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sounds like a virus or malware to me. Here's how to use EnumProcesses()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

a cat, a dog, 3 fish, 2 kids and 2 grandkids.

<M/> commented: ahh... the children. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on the compiler. Generally, DEBUG is defined when you want to compile the program for debugging -- the compiler adds a great deal of symbol information and data so that you can use a debugger to single-step through the program and view the value of variables at any given time. All that is compiler dependent. With Microsoft Visual Studio you don't have to explicitly define DEBUG because the MS compiler with do that for you when you select Debug build (instead of Release build). DEBUG affects the entire program instead of just certain parts.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is how to refer to members of specific classes

int main()
{
    S2 obj;
    obj.A::x = 123;
    std::cout << obj.A::x;
    return 0;
}
nmakes commented: Thanks. THat's what I needed! :D +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Secondly.. Does the 'NEXT' pointer in the first node point just to a memory location of the second node

Yes, exactly right.

Intuitevly.. I would think that there would have to be some form of increment to identify each node

Yes, you have to create one so that the program can iterate through all the nodes

void foo(struct node* head)
{
    struct node* iterator; 

    iterator = head;
    while( iterator != NULL)
    {
        // do something

        iterator = iterator->next; // point to the next node
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For one, why is it that when this second node is instantiated it does not totally overwrite the first node?

Because they are in different memory locations. It's somewhat the same concept as declaring simple variables inside a function

void foo()
{
   int x; // one variable
   int z; // another variable
}

In the above example x and z are completely different variables with occupy different memory locations.

void foo()
{
   int* x = new int;
   int* z = new int;
}

The above example is almost the same as the first except the integers are allocated dynamically, each integer has a different memory location so tha one does not overwrite the other

struct node
{
    struct node* next;
}

void foo()
{
    int* head = NULL;

    struct node* newnode;
    newnode = new struct node; // allocate a node
    head = newnode; // save address in head
    newnode = new struct node; // allocate another node
    nead->next = newnode; // save it's memory location
    newnode = new struct node; // allocate another node
    nead->next->next = newnode; // save it's memory location
}

The above code allocates new memory for each node then saves those locations in the head node. After the address of the new node is stored in head we can throw away the address contained in newnode as it is no longer needed. Yes, the address in newnode is overwritten each time and that is why we have to …

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 20: fgets() parameters are all wrong. Read the description for that function here. I think you should just delete lines 20-23.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You could -- but you may never use that PC again. I hope you realize I was just joking :)

aVar++ commented: I was curious as I read somewhere a guy cleaned his motherboard with soap and water then let it dry, then you said it :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

or maybe this

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you attempt to run the program as administrator? Right-click the executable and you should see a menu item to Run as Administrator. Even though your account may have administrative rights doesn't mean you automatically have all administrative privaledes. Unfortunate, but that is the way it works with Windows 7 and 8.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The easiest solution is not necessarily the best solution. When writing programs you have to consider the "stupid users" factor by making your program as non-breakable as possible. Murphy's Law -- if anythihng can go wrong, it will. Don't expect averyone to enter perfect data -- when testing your program you have to now only test the the right data but also the wrong data. Make an effort to see what breaks your program then make changes to guard against it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You didn't answer my original question -- have you installed Service Pack #5 or #6 for VC++ 6.0? There's no point in us trying to find your problem(s) if you haven't because the original compiler contains bugs in the file i/o header files. One of the bugs was that you had to press Enter twice for cin.

If you have not installed it, you need to download it from here and install it.

adil.ghori commented: thank you .. this is something i found out.. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here are some errors from VS 2012

c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(483): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(487): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
1> Generating Code...
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(34): error C4700: uninitialized local variable 'selection' used
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(311): warning C4715: 'Cus' : not all control paths return a value
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(235): warning C4715: 'SaleR' : not all control paths return a value
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(450): warning C4715: 'Check' : not all control paths return a value
1>c:\dvlp\consoleapplication2\consoleapplication2\consoleapplication2.cpp(520): warning C4715: 'Mile' : not all control paths return a value

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

check line 265 -- all that is getting is one character, not the complete string.

line 288: why are you calling strlen() to do something that std::string.length() already gives you?

adil.ghori commented: thank you +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe we should just run all the bills/laws that congress and the pres have passed over the past 200+ years through a paper shredder and start all over again with the basics of what is in the US Constitution.

That would mean: No social security, No Medicare, No pensions, No unemployment income, No welfare, No disability insurance, No department of defense, No Medicaid, No Health and Human services, and No spending on Transportation..

YES YES YES

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't have to write it yourself, there's already a media control. Read this article

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lets pretend you attend a 12 cinima movie threater. Inside one of the 12 cinimas you will find several rows of seats, each row contains any number of seats. That is a 2d array of seats

Now you can consider the entire cinima threater as a 3d array -- the first dimension represents each of the 12 cinimas, and inside each cinima is a 2d array of seats

So if you represent all the seats liks this

int const NumberCinimas = 12;
int const NumberRows = 15;
int const NumberSeatsPerRow = 20;

int Seats[NumberCinimas][NumberRows][NumberSeatsPerRow];

To assign a seat to someone you will need to know the cinima he wants to watch, and an empty seat in the desired row. So I can buy a ticket for cinima #3, row 15, seat 4

Seats[3][15][4] = AncientDragon;