From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: evaluate cpp snippet in org babel with default includes and customized entry point Date: Sat, 16 Sep 2017 10:33:58 +0200 Message-ID: <59BCE1F6.3060406@free.fr> References: <877ewz9j4x.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dt8Y9-00034Z-ED for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:34:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dt8Y5-0005s4-Dm for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:34:05 -0400 Received: from smtp1-g21.free.fr ([212.27.42.1]:61712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dt8Y5-0005rh-7h for emacs-orgmode@gnu.org; Sat, 16 Sep 2017 04:34:01 -0400 Received: from [IPv6:2a01:e35:2e21:def0:997a:f49e:9a7c:91e1] (unknown [IPv6:2a01:e35:2e21:def0:997a:f49e:9a7c:91e1]) by smtp1-g21.free.fr (Postfix) with ESMTP id 94F56B00535 for ; Sat, 16 Sep 2017 10:33:58 +0200 (CEST) In-Reply-To: <877ewz9j4x.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org A starting point could be as follows. Type C-c C-c to evaluate. Type C-c C-v v to expand the source. #+BEGIN_SRC C++ :flags -std=3Dc++11 #include #include using namespace std; class Solution { public: vector twoSum(vector& nums, int target) { vector result; result.push_back(0); result.push_back(1); return result; } }; vector nums =3D {2, 7, 11, 15}; int target =3D 9; int main() { Solution solution; for (int x : solution.twoSum(nums,target)) cout< > Hi > > I'd like to write a blog about leetcode solutions in c++. How can I=20 > evaluate those c++ code snippet using org babel? > > > 1 Array > > > 1.1 Two Sum > > Given an array of integers, return indices of the two numbers such=20 > that they add up to a specific target. > > You may assume that each input would have exactly one solution, and=20 > you may not use the same element twice. > > Example: > Given nums =3D [2, 7, 11, 15], target =3D 9, > > Because nums[0] + nums[1] =3D 2 + 7 =3D 9, > return [0, 1]. > > |class Solution { > public: > vector twoSum(vector&nums,int target) { > > } > }; > | > > I need to add default headers and pass arguments to the entry class. > > =96 > Amos Bird > amosbird@gmail.com >