Sponsored Content
Full Discussion: Template problem ...
Top Forums Programming Template problem ... Post 302239551 by amartya_sock on Wednesday 24th of September 2008 02:32:02 AM
Old 09-24-2008
Template problem ...

Hi all,
Need your help. I am doing a simple template program , getting some error ... here is the code

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
class Base_class
{
public:
Base_class(){ };
~Base_class(){ };
template <class T>
static int fun(T decimal_value,string& check)
{
ostringstream ostr;
ostr<<decimal_value<<endl;
string str=ostr.str();
check=str;
return 0;
}
};
int main()
{
try
{
string check;
int a=7777;
Base_class ::fun(a,check);
cout<<check<<endl;
double b=7777.9755;
Base_class::fun(b,check);
cout<<check<<endl;
char c[]="AMARTYA";
Base_class::fun(c,check);
cout<<check<<endl;
}
catch(...)
{
cout<<"Function Cutil::failed"<<endl;
}
return 0;
}

This code works fine ....
But i want the Definition of the function not in the main class , i want to put it outside function ......
If i do that ..... It is giving error .....
Please provide some solution(s)...
 

6 More Discussions You Might Find Interesting

1. Programming

About template constraints

Hi, i have class template, 1)can i override the copy constructor 2)can we have virtual function in class template if not plz tel why? I tried , compile error comes for me... Thanks Sarwan (0 Replies)
Discussion started by: sarwan
0 Replies

2. UNIX for Dummies Questions & Answers

vi calling template

Hello. I want to copy temp files when I make a new file by vi. For example, 09:32:52 ~/ $ mkdir test 09:33:03 ~/ $ cd test/ 09:33:09 ~/test/ $ ls 09:33:16 ~/test/ $ vi test.cpp 09:34:37 ~/test/ $ cat test.cpp #include <iostream> int main() { } 09:34:48 ~/test/ $ vi test.bash 09:35:19... (1 Reply)
Discussion started by: Euler04
1 Replies

3. Shell Programming and Scripting

Help with template like solution

hi experts, i'm trying to do this: file1 is a template. might have kinds of 'funny' characters. sample: <body> <form> <p><input type="text" name="abc"/></p> &nbsp; <p><my_content></p> </form> </body> file2 is a file that contains lots of text. this might be very big. might have... (2 Replies)
Discussion started by: xjohnu
2 Replies

4. Programming

C++ template error

I get some compiling errors about template instantiation :wall: , but I can't find where the syntax errors happens. Can some help me? template<typename Type> class SingleList; template<typename Type> class SingleListNode{ private: friend class SingleList<Type>; SingleListNode() :... (1 Reply)
Discussion started by: 915086731
1 Replies

5. Programming

Calling template at once

Hello Again, I am just wanted to know if we can call the Template using "require_once" at PHP? Any views around happy to discuss. Thanks in Advance (2 Replies)
Discussion started by: AimyThomas
2 Replies

6. UNIX for Dummies Questions & Answers

Cacti SNMP Generic OID template, NaN problem

Hello All, I have installed cacti and I have Nan values on created graph. I really appreciate any help. I have done the following: 1. Linux Ubuntu 12.04.2 LTS 64 bits 2. apt-get install cacti // the cacti Version 0.8.7i was installed 3. Accessed "http://MyIP/cacti/index.php" 4. Set SNMP... (0 Replies)
Discussion started by: AndreiM
0 Replies
Template::Tiny(3pm)					User Contributed Perl Documentation				       Template::Tiny(3pm)

NAME
Template::Tiny - Template Toolkit reimplemented in as little code as possible SYNOPSIS
my $template = Template::Tiny->new( TRIM => 1, ); # Print the template results to STDOUT $template->process( <<'END_TEMPLATE', { foo => 'World' } ); Hello [% foo %]! END_TEMPLATE DESCRIPTION
Template::Tiny is a reimplementation of a subset of the functionality from Template Toolkit in as few lines of code as possible. It is intended for use in light-usage, low-memory, or low-cpu templating situations, where you may need to upgrade to the full feature set in the future, or if you want the retain the familiarity of TT-style templates. For the subset of functionality it implements, it has fully-compatible template and stash API. All templates used with Template::Tiny should be able to be transparently upgraded to full Template Toolkit. Unlike Template Toolkit, Template::Tiny will process templates without a compile phase (but despite this is still quicker, owing to heavy use of the Perl regular expression engine. SUPPORTED USAGE Only the default "[% %]" tag style is supported. Both the "[%+ +%]" style explicit whitespace and the "[%- -%]" style explicit chomp are support, although the "[%+ +%]" version is unneeded in practice as Template::Tiny does not support default-enabled "PRE_CHOMP" or "POST_CHOMP". Variable expressions in the form "[% foo.bar.baz %]" are supported. Appropriate simple behaviours for "ARRAY" references, "HASH" references and objects are supported. "VMethods" such as [% array.length %] are not supported at this time. "IF", "ELSE" and "UNLESS" conditional blocks are supported, but only with simple "[% foo.bar.baz %]" conditions. Support for looping (or rather iteration) is available in simple "[% FOREACH item IN list %]" form is supported. Other loop structures are not supported. Because support for arbitrary or infinite looping is not available, Template::Tiny templates are not turing complete. This is intentional. All of the four supported control structures "IF"/"ELSE"/"UNLESS"/"FOREACH" can be nested to arbitrary depth. The treatment of "_private" hash and method keys is compatible with Template Toolkit, returning null or false rather than the actual content of the hash key or method. Anything beyond the above is currently out of scope. METHODS
new my $template = Template::Tiny->new( TRIM => 1, ); The "new" constructor is provided for compatibility with Template Toolkit. The only parameter it currently supports is "TRIM" (which removes leading and trailing whitespace from processed templates). Additional parameters can be provided without error, but will be ignored. process # DEPRECATED: Return template results (emits a warning) my $text = $template->process( $input, $vars ); # Print template results to STDOUT $template->process( $input, $vars ); # Generate template results into a variable my $output = ''; $template->process( $input, $vars, $output ); The "process" method is called to process a template. The first parameter is a reference to a text string containing the template text. A reference to a hash may be passed as the second parameter containing definitions of template variables. If a third parameter is provided, it must be a scalar reference to be populated with the output of the template. For a limited amount of time, the old deprecated interface will continue to be supported. If "process" is called without a third parameter, and in scalar or list contest, the template results will be returned to the caller. If "process" is called without a third parameter, and in void context, the template results will be "print()"ed to the currently selected file handle (probably "STDOUT") for compatibility with Template. SUPPORT
Bugs should be reported via the CPAN bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Tiny <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Tiny> For other issues, or commercial enhancement or support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
Config::Tiny, CSS::Tiny, YAML::Tiny COPYRIGHT
Copyright 2009 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.12.3 2011-06-17 Template::Tiny(3pm)
All times are GMT -4. The time now is 08:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy