Visual Studio 2010

Hi all,
first of anything else I feel compelled to sincerely thank all those who have made ROOT possible. I began using it today from VisualStudio 2010.
I wrote the following console application in Visual Studio 2010:

// Esercizi Libro.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>

#include <Windows4Root.h>
#include "TApplication.h"
#include "TH1D.h"
#include "THistPainter.h"
#include "TCanvas.h"
#include "TBenchmark.h"
#include "TSlider.h"
#include "TRandom.h"
#include "TMinuit.h"
#include "TFormula.h"
#include "TF1.h"
#include "TObjectTable.h"

using namespace std;


int main()
{	
   //Display interpreted functions
   //Author: Rene Brun

   //
   // To see the graphics output of this macro, click begin_html <a href="gif/formula1.gif">here</a>. end_html
   //
   TCanvas *c1 = new TCanvas("c1","Example with Formula",200,10,700,500);
   //
   // We create a formula object and compute the value of this formula
   // for two different values of the x variable.
   //
   auto form1 = new TFormula("form1","sqrt(abs(x))");
   form1->Eval(2);
   form1->Eval(-45);
   //
   // Create a one dimensional function and draw it
   //
   auto fun1 = new TF1("fun1","abs(sin(x)/x)",0,10);
   c1->SetGridx();
   c1->SetGridy();
   fun1->Draw();
   c1->Update();
   //
   // Before leaving this demo, we print the list of objects known to ROOT
   //
   if (gObjectTable) gObjectTable->Print();

	system("pause");
	return 0;
}

I apologize for all the headers listed but I did a lot of attempts and they added up.
This compiles perfectly, runs perfectly ( it is taken from one of your examples, by the way ), the ROOT window opens and prints the list of all objects … but no chart ! :confused:
Did I blunder anywhere ? For sure !
Would anyone be so kind to put me on the right path ?
Thank you in advance !

Hi,

You must create a TApplication instance. For example:

[code]int main(int argc, char **argv)
{
TApplication theApp(“My App”, &argc, argv);

// your code comes here…

theApp.Run();
return 0;
}[/code]
Cheers, Bertrand.

.

Thanks a lot, Bertrand, now it works like a charm ! :smiley:
Just a curiosity: let’s suppose I had declared main as int main() ( without argc and argv )
what would be the arguments of TApplication ?
I can not write TApplication theApp(“My App”, &argc, argv) because the last 2 arguments do not exist anymore
& I can not write just TApplication theApp(“My App”) because the compiler answers there are more arguments

Thank you again,

Francesco

“My App”, 0, 0

Thanks a lot !
Just the last question, promised !
My results will be typically contained in arrays.
How should I modify the above code to plot the elements of an array instead of a function ?
And to plot an array of x against an array of y ?

TGraph
TGraphErrors
TGraphAsymmErrors
TGraphBentErrors
TGraphPolar

TGraph2D
TGraph2DErrors

TMultiGraph

See also: TGraphPainter

And, for the time being, don’t miss this: [url]Problem with the ROOT website

Thanks !!!